on master help sign in
Use Data.Type.Bool for type-level bools
6cee2a9Csongor Kiss
generic-lens.cabal−1
@@ -32,7 +32,6 @@ library
32 , Data.Generics.Internal.Lens
32 , Data.Generics.Internal.Lens
33
33
34 other-modules: Data.Generics.Internal.Families
34 other-modules: Data.Generics.Internal.Families
35− , Data.Generics.Internal.Families.Bool
36 , Data.Generics.Internal.Families.Count
35 , Data.Generics.Internal.Families.Count
37 , Data.Generics.Internal.Families.Has
36 , Data.Generics.Internal.Families.Has
38 , Data.Generics.Internal.HList
37 , Data.Generics.Internal.HList
src/Data/Generics/Internal/Families.hs−1
@@ -2,6 +2,5 @@ module Data.Generics.Internal.Families
2 ( module Families
2 ( module Families
3 ) where
3 ) where
4
4
5−import Data.Generics.Internal.Families.Bool as Families
6import Data.Generics.Internal.Families.Count as Families
5import Data.Generics.Internal.Families.Count as Families
7import Data.Generics.Internal.Families.Has as Families
6import Data.Generics.Internal.Families.Has as Families
src/Data/Generics/Internal/Families/Bool.hsdeleted−17
@@ -1,17 +0,0 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE KindSignatures #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE TypeOperators #-}
5−
6−module Data.Generics.Internal.Families.Bool
7− ( type (||)
8− , type (&&)
9− ) where
10−
11−type family (a :: Bool) || (b :: Bool) :: Bool where
12− 'True || _ = 'True
13− _ || b = b
14−
15−type family (a :: Bool) && (b :: Bool) :: Bool where
16− 'True && 'True = 'True
17− _ && _ = 'False
src/Data/Generics/Internal/Families/Has.hs+2−2
@@ -11,11 +11,11 @@ module Data.Generics.Internal.Families.Has
11 , HasCtorP
11 , HasCtorP
12 ) where
12 ) where
13
13
14−import Data.Generics.Internal.Families.Bool
15−
16import GHC.Generics
14import GHC.Generics
17import GHC.TypeLits
15import GHC.TypeLits
18
16
17+import Data.Type.Bool (type (||), type (&&))
18+
19type family HasTotalFieldP (field :: Symbol) f :: Bool where
19type family HasTotalFieldP (field :: Symbol) f :: Bool where
20 HasTotalFieldP field (S1 ('MetaSel ('Just field) _ _ _) (Rec0 t))
20 HasTotalFieldP field (S1 ('MetaSel ('Just field) _ _ _) (Rec0 t))
21 = 'True
21 = 'True
src/Data/Generics/Product/Positions.hs+4−19
@@ -40,6 +40,8 @@ import Data.Kind
40import GHC.Generics
40import GHC.Generics
41import GHC.TypeLits
41import GHC.TypeLits
42
42
43+import Data.Type.Bool (type (&&), If, Not)
44+
43-- $example
45-- $example
44-- @
46-- @
45-- module Example where
47-- module Example where
@@ -154,24 +156,7 @@ type family Size f :: Nat where
154
156
155--------------------------------------------------------------------------------
157--------------------------------------------------------------------------------
156
158
157−type family Not (b :: Bool) where
158− Not 'True = 'False
159− Not 'False = 'True
160−
161−type family (<?) (x :: Nat) (y :: Nat) :: Bool where
162− x <? y = Not (y <=? x)
159+type x <? y = Not (y <=? x)
163−
164infixl 4 <?
160infixl 4 <?
165
161
166−type family If (c :: Bool) (x :: k) (y :: k) :: k where
167− If 'True x _ = x
168− If 'False _ y = y
169−
170−type family Min (a :: Nat) (b :: Nat) :: Nat where
171− Min a b = If (a <? b) a b
162+type Min a b = If (a <? b) a b
172−
173−type family (a :: Bool) && (b :: Bool) :: Bool where
174− 'True && 'True = 'True
175− _ && _ = 'False
176−
177−infix 3 &&