rerefined-0.3.0: Refinement types, again
Safe HaskellSafe-Inferred
LanguageGHC2021

Rerefined.Predicate.Relational.Length

Synopsis

Documentation

data CompareLength op (n :: Natural) Source #

Compare length to a type-level Natural using the given RelOp.

Instances

Instances details
(KnownNat n, Foldable f, ReifyRelOp op, KnownPredicateName (CompareLength op n)) => Refine1 (CompareLength op n :: Type) (f :: Type -> Type) Source #

Compare the length of a Foldable to a type-level Natural using the given RelOp.

Instance details

Defined in Rerefined.Predicate.Relational.Length

Methods

validate1 :: forall (a :: k1). Proxy# (CompareLength op n) -> f a -> Maybe RefineFailure Source #

Predicate (CompareLength op n :: Type) Source #

Precedence of 4 (matching base relational operators e.g. >=).

Instance details

Defined in Rerefined.Predicate.Relational.Length

Associated Types

type PredicateName d (CompareLength op n) :: Symbol Source #

(KnownNat n, MonoFoldable a, ReifyRelOp op, KnownPredicateName (CompareLength op n)) => Refine (CompareLength op n :: Type) a Source #

Compare the length of a MonoFoldable to a type-level Natural using the given RelOp.

Instance details

Defined in Rerefined.Predicate.Relational.Length

type PredicateName d (CompareLength op n :: Type) Source # 
Instance details

Defined in Rerefined.Predicate.Relational.Length

type PredicateName d (CompareLength op n :: Type) = ShowParen (d > 4) ((("Length " ++ ShowRelOp op) ++ ShowChar ' ') ++ ShowNatDec n)

widenCompareLength :: forall m op n a. WROE op n m => Refined (CompareLength op n) a -> Refined (CompareLength op m) a Source #

Widen a length comparison predicate.

Only valid widenings are permitted, checked at compile time.

Example: Given a >= 1, we know also that a >= 0. Thus, this function allows you to turn a Refined (CompareLength GTE 1) a into a Refined (CompareLength GTE 0) a.

TODO improve type error here

widenCompareLength1 :: forall m op n f a. WROE op n m => Refined1 (CompareLength op n) f a -> Refined1 (CompareLength op m) f a Source #

Widen a length comparison predicate.

Only valid widenings are permitted, checked at compile time.

Example: Given a >= 1, we know also that a >= 0. Thus, this function allows you to turn a Refined1 (CompareLength GTE 1) f a into a Refined1 (CompareLength GTE 0) f a.

TODO improve type error here

type WROE op n m = WROE' op n m (WidenRelOp op n m) Source #

type family WROE' op n m b where ... Source #

Equations

WROE' op n m True = () 
WROE' op n m False = TypeError (((Text "can't widen relational equation " :$$: ((ShowType op :<>: Text " ") :<>: ShowType n)) :$$: Text "to") :$$: ((ShowType op :<>: Text " ") :<>: ShowType m))