]> Git — Sourcephile - comptalang.git/blob - cli/Hcompta/Expr/Trans.hs
Adapte hcompta-cli.
[comptalang.git] / cli / Hcompta / Expr / Trans.hs
1 {-# LANGUAGE FlexibleInstances #-}
2 {-# LANGUAGE MultiParamTypeClasses #-}
3 {-# LANGUAGE NoImplicitPrelude #-}
4
5 module Hcompta.Expr.Trans where
6
7 import Data.Function ((.))
8
9 -- |
10 -- * 'trans_lift' is generally not /surjective/
11 -- * 'trans_apply' is not /injective/
12 -- * 'trans_apply' . 'trans_lift' == 'id'
13 -- * 'trans_lift' . 'trans_apply' /= 'id'
14 class Trans trans repr where
15 trans_lift :: repr a -> trans repr a
16 trans_apply :: trans repr a -> repr a
17
18 trans_map1 :: (repr a -> repr b) -> (trans repr a -> trans repr b)
19 trans_map1 f = trans_lift . f . trans_apply
20
21 trans_map2
22 :: (repr a -> repr b -> repr c)
23 -> (trans repr a -> trans repr b -> trans repr c)
24 trans_map2 f e1 e2 = trans_lift (f (trans_apply e1) (trans_apply e2))