module Graphics.FieldTrip.Transform (Transform(..), Invertible(..)) where
import Control.Arrow ((***))
infixr 7 *%
class Transform xf a where
(*%) :: xf -> a -> a
instance (Transform xf a, Transform xf b) => Transform xf (a,b) where
(*%) xf = (*%) xf *** (*%) xf
instance (Transform xf a, Transform xf b, Transform xf c)
=> Transform xf (a,b,c) where
xf *% (a,b,c) = (xf *% a, xf *% b, xf *% c)
instance (Transform xf a, Transform xf b, Transform xf c, Transform xf d)
=> Transform xf (a,b,c,d) where
xf *% (a,b,c,d) = (xf *% a, xf *% b, xf *% c, xf *% d)
class Invertible xf where
inverse :: xf -> xf
instance (Invertible xf, Transform xf a, Transform xf b)
=> Transform xf (a -> b) where
xf *% f = (xf *%) . f . (inverse xf *%)