Safe Haskell | None |
---|---|
Language | Haskell2010 |
Type - level assertion utility leveraging custom TypeError
s
- type family Assert (cond :: Assertion a) (x :: a) :: a where ...
- type Assertion a = TyFun a (Maybe ErrorMessage) -> Type
- type family Check (f :: Assertion a) (x :: a) :: Maybe ErrorMessage
- type (?::) x cond = Assert cond x
- data (@&&) :: Assertion a -> Assertion a -> Assertion a
- data NatLE :: Nat -> Assertion Nat
- data NatGE :: Nat -> Assertion Nat
- data NatIn :: Nat -> Nat -> Assertion Nat
- data LengthIn :: Nat -> Nat -> Assertion a
- type family CountElementsForLengthIn (xs :: k) :: Nat
Documentation
type family Assert (cond :: Assertion a) (x :: a) :: a where ... Source #
type family Check (f :: Assertion a) (x :: a) :: Maybe ErrorMessage Source #
Apply Assertion
s to the actual values.
data (@&&) :: Assertion a -> Assertion a -> Assertion a Source #
Assert that two assertions both hold
type Check (Maybe ErrorMessage) ((@&&) (Maybe ErrorMessage) a1 a2) x Source # | |
data LengthIn :: Nat -> Nat -> Assertion a Source #
Assert that a list's length falls into a given range.
This is generalized from actual lists; everything with a CountElementsForLengthIn
instance can be asserted.
type family CountElementsForLengthIn (xs :: k) :: Nat Source #
type CountElementsForLengthIn [k] ([] k) Source # | |
type CountElementsForLengthIn [a] ((:) a x xs) Source # | |