Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utils for type lists
Synopsis
- type family Snoc (xs :: [k]) (x :: k) :: [k] where ...
- type family Concat (xs :: [k]) (ys :: [k]) :: [k] where ...
- type family Replicate (n :: Nat) (s :: k) :: [k] where ...
- type family Zip (l :: [*]) (l2 :: [*]) where ...
- type family RemoveAt (n :: Nat) (l :: [k]) :: [k] where ...
- type family RemoveAt1 (n :: Nat) (l :: [k]) :: [k] where ...
- type family RemoveAtN (ns :: [Nat]) (l :: [k]) :: [k] where ...
- type family Remove (a :: k) (l :: [k]) :: [k] where ...
- type family Nub (l :: [k]) :: [k] where ...
- type family NubHead (l :: [k]) :: [k] where ...
- type family Head (xs :: [k]) :: k where ...
- type family Tail (xs :: [k]) :: [k] where ...
- type family Init (xs :: [k]) :: [k] where ...
- type family Take (n :: Nat) (xs :: [k]) :: [k] where ...
- type family Drop (n :: Nat) (xs :: [k]) :: [k] where ...
- type family InsertAt (n :: Nat) (l :: [k]) (l2 :: [k]) :: [k] where ...
- type family ReplaceAt (n :: Nat) (l :: [k]) (l2 :: [k]) :: [k] where ...
- type family Replace (t1 :: k) (t2 :: k) (l :: [k]) :: [k] where ...
- type family ReplaceN (n :: Nat) (t :: k) (l :: [k]) :: [k] where ...
- type family ReplaceNS (ns :: [Nat]) (t :: k) (l :: [k]) :: [k] where ...
- type family CheckMember (a :: k) (l :: [k]) :: Constraint where ...
- type family CheckMembers (l1 :: [k]) (l2 :: [k]) :: Constraint where ...
- type family Union (xs :: [k]) (ys :: [k]) :: [k] where ...
- type family Complement (xs :: [k]) (ys :: [k]) :: [k] where ...
- type family Product (xs :: [*]) (ys :: [*]) :: [*] where ...
- type Member x xs = (x ~ Index (IndexOf x xs) xs, KnownNat (IndexOf x xs))
- type family Members xs ys :: Constraint where ...
- type CheckNub (l :: [k]) = CheckNubEx l (Nub l) ~ True
- type family IndexOf (a :: k) (l :: [k]) :: Nat where ...
- type family IndexesOf (a :: k) (l :: [k]) :: [Nat] where ...
- type family MaybeIndexOf (a :: k) (l :: [k]) where ...
- type family Index (n :: Nat) (l :: [k]) :: k where ...
- type family Reverse (l :: [k]) :: [k] where ...
- type family Generate (n :: Nat) (m :: Nat) :: [Nat] where ...
- type family Map (f :: a -> k) (xs :: [a]) :: [k] where ...
- type family Max (xs :: [Nat]) where ...
- type family Length (xs :: [k]) :: Nat where ...
- type family Indexes (l :: [k]) :: [Nat] where ...
- type family MapTest (a :: k) (l :: [k]) :: [Nat] where ...
Construction
type family Replicate (n :: Nat) (s :: k) :: [k] where ... Source #
Replicate
Replicate n s = Replicate' s n '[] |
Removal
type family RemoveAt1 (n :: Nat) (l :: [k]) :: [k] where ... Source #
Remove a type at index (0 == don't remove)
type family RemoveAtN (ns :: [Nat]) (l :: [k]) :: [k] where ... Source #
Remove types at several indexes
Sublist
Insert/replace
type family ReplaceAt (n :: Nat) (l :: [k]) (l2 :: [k]) :: [k] where ... Source #
replace l[n] with l2 (folded)
type family Replace (t1 :: k) (t2 :: k) (l :: [k]) :: [k] where ... Source #
replace a type by another in l
type family ReplaceN (n :: Nat) (t :: k) (l :: [k]) :: [k] where ... Source #
replace a type at offset n in l
type family ReplaceNS (ns :: [Nat]) (t :: k) (l :: [k]) :: [k] where ... Source #
replace types at offsets ns in l
Set operations
type family CheckMember (a :: k) (l :: [k]) :: Constraint where ... Source #
Check that a type is member of a type list
CheckMember a l = CheckMember' l a l |
type family CheckMembers (l1 :: [k]) (l2 :: [k]) :: Constraint where ... Source #
Check that a list is a subset of another
CheckMembers l1 l1 = () | |
CheckMembers l1 l2 = CheckMembers' l2 '[] l1 l2 |
type family Complement (xs :: [k]) (ys :: [k]) :: [k] where ... Source #
Complement xs ys
Complement xs '[] = xs | |
Complement xs (y ': ys) = Complement (Remove y xs) ys |
type Member x xs = (x ~ Index (IndexOf x xs) xs, KnownNat (IndexOf x xs)) Source #
Constraint: x member of xs
type family Members xs ys :: Constraint where ... Source #
Constraint: all the xs are members of ys
type CheckNub (l :: [k]) = CheckNubEx l (Nub l) ~ True Source #
Check that a list only contain a value of each type
Index operations
type family IndexOf (a :: k) (l :: [k]) :: Nat where ... Source #
Get the first index of a type
IndexOf x xs = IndexOf' x xs xs |
type family IndexesOf (a :: k) (l :: [k]) :: [Nat] where ... Source #
Get all the indexes of a type
IndexesOf x xs = IndexesOf' 0 x xs |
type family MaybeIndexOf (a :: k) (l :: [k]) where ... Source #
Get the first index (starting from 1) of a type or 0 if none
MaybeIndexOf x xs = MaybeIndexOf' 0 x xs |
Nat list
type family Generate (n :: Nat) (m :: Nat) :: [Nat] where ... Source #
Generate a list of Nat [n..m-1]
Others
type family Max (xs :: [Nat]) where ... Source #
Get the max of a list of Nats
Max (x ': xs) = Max' x xs |