]> Git — Sourcephile - haskell/symantic-base.git/blob - src/Symantic/Dityped/Composable.hs
clean up indentation
[haskell/symantic-base.git] / src / Symantic / Dityped / Composable.hs
1 module Symantic.Dityped.Composable where
2
3 import Symantic.Dityped.Transformable
4
5 -- * Class 'Composable'
6 class Composable repr where
7 (<.>) :: repr a b -> repr b c -> repr a c
8 (<.>) = lift2 (<.>)
9 default (<.>) ::
10 Liftable2 repr => Composable (Unlifted repr) =>
11 repr a b -> repr b c -> repr a c
12 infixr 4 <.>
13
14 -- * Class 'Voidable'
15 class Voidable repr where
16 default void ::
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)
21
22 -- ** Type 'IdentityTrans'
23 -- | A 'Transformable' that does nothing.
24 newtype IdentityTrans repr a k
25 = IdentityTrans
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
31 trans = IdentityTrans
32
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)
37 default dimap ::
38 Liftable1 repr => Dimapable (Unlifted repr) =>
39 (a->b) -> (b->a) -> repr (a->k) k -> repr (b->k) k