on master help sign in
typeable/ether/src/Ether/Internal.hs
68 lines 1.3 kB history raw
1module Ether.Internal
2 ( Tagged(..)
3 , TagsK
4 , Tags
5 , HasLens(..)
6 , LensLike
7 , Lens
8 , Lens'
9 , ReifiedLens(..)
10 , ReifiedLens'
11 , view
12 , over
13 , HList(..)
14 , KindOf
15 , TAGGED
16 , HandleSuper
17 , HandleConstraint
18 , Handle(..)
19 , makeTupleInstancesHasLens
20 ) where
22import Control.Applicative
23import Data.Coerce
24import Data.Functor.Identity
25import Data.Kind
26import Data.Tagged
27import GHC.Exts (Constraint)
29import Ether.Internal.HasLens
30import Ether.Internal.Tags
31import Ether.Internal.TH_TupleInstances (makeTupleInstancesHasLens)
32import Ether.Internal.TupleInstances ()
34data TAGGED e t
36type K_Monad = Type -> Type
38type K_Trans = K_Monad -> K_Monad
40type family
41 HandleSuper
42 (eff :: keff)
43 (p :: kp)
44 (trans :: K_Trans)
45 :: Constraint
47type family
48 HandleConstraint
49 (eff :: keff)
50 (p :: kp)
51 (trans :: K_Trans) (m :: K_Monad)
52 :: Constraint
54class
55 HandleSuper eff p trans =>
56 Handle eff p (trans :: K_Trans) | eff trans -> p
57 where
58 handling :: Monad m => (HandleConstraint eff p trans m => r) -> r
60newtype ReifiedLens s t a b = Lens (Lens s t a b)
62type ReifiedLens' s a = ReifiedLens s s a a
64view :: LensLike (Const a) s t a b -> s -> a
65view l = coerce (l Const)
67over :: LensLike Identity s t a b -> (a -> b) -> s -> t
68over = coerce