git.iko.soy/typeable/control-has
on master help sign in
adjust to base 4.18 (ghc-9.6.3)
commit2b0b246bd94ead0dbcba15526e21f58b977fe4bb authorDmitry Olshansky <olshanskydr@gmail.com> dateWed 3 Jan 2024, 19:23 (3 years ago) parent017dd75
2 files changed+16−12
src/Control/EnvT.hs+5−1 src/Control/Has.hs+11−11
src/Control/EnvT.hs+5−1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE TemplateHaskell #-}
23
34module Control.EnvT
@@ -13,12 +14,15 @@ import Control.Lens
1314import Control.Monad.Base
1415import Control.Monad.Catch
1516import Control.Monad.Except
16−import Control.Monad.Fail
1717import Control.Monad.Reader as X
1818import Control.Monad.Trans.Control
1919import Control.Monad.Trans.Resource
2020import Control.Monad.Zip
2121
22+#if MIN_VERSION_base(4,18,0)
23+import Control.Monad
24+import Control.Monad.Fix
25+#endif
2226
2327-- | The only reason this exists is that there are a lot of instances for
2428-- 'EnvT, which simply pass the implementation to the inner 'm'
src/Control/Has.hs+11−11
@@ -20,11 +20,11 @@ class Has x r where
2020instance {-# OVERLAPS #-} Has r r where
2121 part = id
2222
23−type family HasAll (xs :: [*]) r :: Constraint where
23+type family HasAll (xs :: [Type]) r :: Constraint where
2424 HasAll '[] r = ()
2525 HasAll (x ': xs) r = (Has x r, HasAll xs r)
2626
27−data LensList (r :: *) (es :: [*]) where
27+data LensList (r :: Type) (es :: [Type]) where
2828 LLNil :: LensList r '[]
2929 LLCons :: Lens r r e e -> LensList r es -> LensList r (e ': es)
3030
@@ -32,7 +32,7 @@ mapLL :: Lens s s r r -> LensList r es -> LensList s es
3232mapLL _ LLNil = LLNil
3333mapLL m (LLCons l ls) = LLCons (m . l) (mapLL m ls)
3434
35−type family (xs :: [*]) ++ (ys :: [*]) :: [*] where
35+type family (xs :: [Type]) ++ (ys :: [Type]) :: [Type] where
3636 '[] ++ ys = ys
3737 (x ': xs) ++ ys = x ': (xs ++ ys)
3838
@@ -43,7 +43,7 @@ concatLL (LLCons l ls) ys = LLCons l (concatLL ls ys)
4343-- borrowed from Data.HSet.Get
4444data N = Z | S N
4545
46−type family IndexOf (x :: *) (xs :: [*]) :: N where
46+type family IndexOf (x :: Type) (xs :: [Type]) :: N where
4747 IndexOf x (x ': _) = 'Z
4848 IndexOf x (_ ': xs) = 'S (IndexOf x xs)
4949
@@ -52,8 +52,8 @@ class (i ~ IndexOf e es) => GetLens e es i | i es -> e where
5252
5353type Elem e es = GetLens e es (IndexOf e es)
5454
55−class Fieldy (r :: *) where
56− type Fields r :: [*]
55+class Fieldy (r :: Type) where
56+ type Fields r :: [Type]
5757 type Fields r = GFields (Rep r)
5858 lensList :: LensList r (Fields r)
5959 default lensList
@@ -73,16 +73,16 @@ instance (GetLens e' es n, 'S n ~ IndexOf e' (e ': es))
7373 => GetLens e' (e ': es) ('S n) where
7474 getLens (LLCons _ ls) = getLens ls
7575
76−class GFieldy (r :: * -> *) where
77− type GFields r :: [*]
76+class GFieldy (r :: Type -> Type) where
77+ type GFields r :: [Type]
7878 glensList :: LensList (r x) (GFields r)
7979
8080instance GFieldyProduct r => GFieldy (D1 d (C1 c r)) where
8181 type GFields (D1 d (C1 c r)) = GFieldsProduct r
8282 glensList = mapLL (iso unM1 M1 . iso unM1 M1) glensListProduct
8383
84−class GFieldyProduct (r :: * -> *) where
85− type GFieldsProduct r :: [*]
84+class GFieldyProduct (r :: Type -> Type) where
85+ type GFieldsProduct r :: [Type]
8686 glensListProduct :: LensList (r x) (GFieldsProduct r)
8787
8888instance (GFieldyProduct r, GFieldyProduct s) => GFieldyProduct (r :*: s) where
@@ -101,7 +101,7 @@ instance GFieldyProduct (S1 s (K1 k r)) where
101101 type GFieldsProduct (S1 s (K1 k r)) = '[r]
102102 glensListProduct = LLCons (iso unM1 M1 . iso unK1 K1) LLNil
103103
104−type family AllElem (xs :: [*]) (es :: [*]) :: Constraint where
104+type family AllElem (xs :: [Type]) (es :: [Type]) :: Constraint where
105105 AllElem '[] _ = ()
106106 AllElem (x ': xs) es = (Elem x es, AllElem xs es)
107107