1 module Language.Symantic.Transforming.Trans where
4 -- * 'trans' is generally not /surjective/
5 -- * 'unTrans' is not /injective/
6 -- * 'unTrans' . 'trans' == 'id'
7 -- * 'trans' . 'unTrans' /= 'id'
9 -- NOTE: @DefaultSignatures@ can be used
10 -- when declaring a symantic type class
11 -- to provide default definition of the methods:
12 -- implementing their identity transformation
13 -- in order to avoid boilerplate code
14 -- when writting 'Trans' instances which
15 -- do not need to alterate those methods.
17 -- | Return the underlying @tr@ of the transformer.
20 -- | Lift a tr to the transformer's.
21 trans :: UnT tr a -> tr a
22 -- | Unlift a tr from the transformer's.
23 unTrans :: tr a -> UnT tr a
25 -- | Identity transformation for a unary symantic method.
26 trans1 :: (UnT tr a -> UnT tr b) -> (tr a -> tr b)
27 trans1 f = trans . f . unTrans
29 -- | Identity transformation for a binary symantic method.
31 :: (UnT tr a -> UnT tr b -> UnT tr c)
32 -> (tr a -> tr b -> tr c)
33 trans2 f t1 t2 = trans $ f (unTrans t1) (unTrans t2)
35 -- | Identity transformation for a ternary symantic method.
37 :: (UnT tr a -> UnT tr b -> UnT tr c -> UnT tr d)
38 -> (tr a -> tr b -> tr c -> tr d)
39 trans3 f t1 t2 t3 = trans $ f (unTrans t1) (unTrans t2) (unTrans t3)