1 module Symantic.Dityped.Composable where
3 import Symantic.Dityped.Transformable
5 -- * Class 'Composable'
6 class Composable repr where
7 (<.>) :: repr a b -> repr b c -> repr a c
10 Liftable2 repr => Composable (Unlifted repr) =>
11 repr a b -> repr b c -> repr a c
15 class Voidable repr where
16 default void :: Liftable1 repr => Voidable (Unlifted repr) =>
17 a -> repr (a -> b) k -> repr b k
18 void :: a -> repr (a -> b) k -> repr b k
19 void a = lift1 (void a)
21 -- ** Type 'IdentityTrans'
22 -- | A 'Transformable' that does nothing.
23 newtype IdentityTrans repr a k
25 { unIdentityTrans :: repr a k }
26 type instance Unlifted (IdentityTrans repr) = repr
27 instance Transformable (IdentityTrans repr) repr where
28 trans = unIdentityTrans
29 instance Transformable repr (IdentityTrans repr) where
32 -- * Class 'Dimapable'
33 class Dimapable repr where
34 dimap :: (a->b) -> (b->a) -> repr (a->k) k -> repr (b->k) k
35 dimap a2b b2a = lift1 (dimap a2b b2a)
36 default dimap :: Liftable1 repr => Dimapable (Unlifted repr) =>
37 (a->b) -> (b->a) -> repr (a->k) k -> repr (b->k) k