Constraint.hs (1611B)
1 module Lude.Haskell.Constraint ( 2 Constraint, 3 Constraint1, 4 Constraint2, 5 Predicate, 6 Relation, 7 All, 8 ) where 9 10 import Data.Tuple.Experimental qualified as GHC 11 import GHC.Exts qualified as GHC 12 13 import Lude.Haskell.Core 14 import Lude.Haskell.Repr qualified as Repr 15 16 -- TODO: Delete Constraint1/Constraint2 in favor of Predicate/Relation? 17 -- We'd also need a replacement name for Type1. Maybe "Family"? 18 19 -------------------------------------------------------------------------------- 20 21 type Constraint# :: Repr -> Kind 22 type Constraint# = GHC.CONSTRAINT 23 24 type Constraint :: Kind 25 type Constraint = Constraint# Repr.BoxL 26 27 type Constraint1 :: Kind -> Kind 28 type Constraint1 i = i -> Constraint 29 30 type Constraint2 :: Kind -> Kind -> Kind 31 type Constraint2 i j = i -> j -> Constraint 32 33 type Predicate :: Kind -> Kind 34 type Predicate i = Constraint1 i 35 36 type Relation :: Kind -> Kind -> Kind 37 type Relation i j = Constraint2 i j 38 39 -------------------------------------------------------------------------------- 40 41 -- TODO: Synchronize with type tuples. 42 type All :: forall {k}. k -> Constraint 43 type family All _ where 44 All () = GHC.CTuple0 45 All (a) = GHC.CTuple1 a 46 All (a, b) = GHC.CTuple2 a b 47 All (a, b, c) = GHC.CTuple3 a b c 48 All (a, b, c, d) = GHC.CTuple4 a b c d 49 All (a, b, c, d, e) = GHC.CTuple5 a b c d e 50 All (a, b, c, d, e, f) = GHC.CTuple6 a b c d e f 51 All (a, b, c, d, e, f, g) = GHC.CTuple7 a b c d e f g 52 All (a, b, c, d, e, f, g, h) = GHC.CTuple8 a b c d e f g h 53 All (a, b, c, d, e, f, g, h, i) = GHC.CTuple9 a b c d e f g h i 54 All (GHC.MkSolo a) = GHC.CTuple1 a