1 {-# LANGUAGE DefaultSignatures #-}
2 module Symantic.Base.Univariant where
4 -- TODO: move to symantic-base
6 import Data.Function ((.))
8 -- * Type family 'Unlift'
9 type family Unlift (repr :: * -> *) :: * -> *
11 -- * Class 'Unliftable'
12 class Unliftable repr where
13 unlift :: repr a -> Unlift repr a
16 class Liftable repr where
17 lift :: Unlift repr a -> repr a
18 lift1 :: (Unlift repr a -> Unlift repr b) ->
20 lift2 :: (Unlift repr a -> Unlift repr b -> Unlift repr c) ->
21 repr a -> repr b -> repr c
22 lift3 :: (Unlift repr a -> Unlift repr b -> Unlift repr c -> Unlift repr d) ->
23 repr a -> repr b -> repr c -> repr d
26 (Unlift repr a -> Unlift repr b) ->
30 (Unlift repr a -> Unlift repr b -> Unlift repr c) ->
31 repr a -> repr b -> repr c
34 (Unlift repr a -> Unlift repr b -> Unlift repr c -> Unlift repr d) ->
35 repr a -> repr b -> repr c -> repr d
36 lift1 f = lift . f . unlift
37 lift2 f a b = lift (f (unlift a) (unlift b))
38 lift3 f a b c = lift (f (unlift a) (unlift b) (unlift c))