I've written the following code:
{- ...
...
... -}
data Ellipsoid
data Halfplane
data Intersection
data PointSet s a where
Halfplane :: RealFrac a =>
a -> a -> a -> (a -> a -> Bool) -> a ->
PointSet Halfplane a
Ellipsoid :: RealFrac a =>
a -> a -> a -> (a -> a -> Bool) -> a ->
PointSet Ellipsoid a
Intersection :: [PointSet s a] -> PointSet Intersection a
type TestFunc a = RealFrac a => (a -> a -> a -> Bool)
test :: (Show a) => PointSet t a -> TestFunc a
test (Ellipsoid a b c f r) = f'
where f' z y x = ((x/a)^2 + (y/b)^2 + (z/c)^2) `f` r
test (Halfplane a b c f t) = f'
where f' z y x = (a*x + b*y + c*z) `f` t
test (Intersection ps) = f'
where f' z y x = and . map ($ x) $ map ($ y) $ map ($ z) ts
ts = map test ps
In particular I'd like to have input on f' z y x = and . map ($ x) $ map ($ y) $ map ($ z) ts
, whether there is a way to express this more succinctly.
Of course, I'm happy about any other comment as well.