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
17 Liftable1 repr => Voidable (Unlifted repr) =>
18 a -> repr (a -> b) k -> repr b k
19 void :: a -> repr (a -> b) k -> repr b k
20 void a = lift1 (void a)
22 -- ** Type 'IdentityTrans'
23 -- | A 'Transformable' that does nothing.
24 newtype IdentityTrans repr a k
26 { unIdentityTrans :: repr a k }
27 type instance Unlifted (IdentityTrans repr) = repr
28 instance Transformable (IdentityTrans repr) repr where
29 trans = unIdentityTrans
30 instance Transformable repr (IdentityTrans repr) where
33 -- * Class 'Dimapable'
34 class Dimapable repr where
35 dimap :: (a->b) -> (b->a) -> repr (a->k) k -> repr (b->k) k
36 dimap a2b b2a = lift1 (dimap a2b b2a)
38 Liftable1 repr => Dimapable (Unlifted repr) =>
39 (a->b) -> (b->a) -> repr (a->k) k -> repr (b->k) k