module Symantic.Dityped.Composable where import Symantic.Dityped.Transformable -- * Class 'Composable' class Composable repr where (<.>) :: repr a b -> repr b c -> repr a c (<.>) = lift2 (<.>) default (<.>) :: Liftable2 repr => Composable (Unlifted repr) => repr a b -> repr b c -> repr a c infixr 4 <.> -- * Class 'Voidable' class Voidable repr where default void :: Liftable1 repr => Voidable (Unlifted repr) => a -> repr (a -> b) k -> repr b k void :: a -> repr (a -> b) k -> repr b k void a = lift1 (void a) -- ** Type 'IdentityTrans' -- | A 'Transformable' that does nothing. newtype IdentityTrans repr a k = IdentityTrans { unIdentityTrans :: repr a k } type instance Unlifted (IdentityTrans repr) = repr instance Transformable (IdentityTrans repr) repr where trans = unIdentityTrans instance Transformable repr (IdentityTrans repr) where trans = IdentityTrans -- * Class 'Dimapable' class Dimapable repr where dimap :: (a->b) -> (b->a) -> repr (a->k) k -> repr (b->k) k dimap a2b b2a = lift1 (dimap a2b b2a) default dimap :: Liftable1 repr => Dimapable (Unlifted repr) => (a->b) -> (b->a) -> repr (a->k) k -> repr (b->k) k