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

Rerefined.Predicate

Description

Base definitions for refinement predicates.

Synopsis

Documentation

class Predicate p => Refine p a where Source #

Refine a with predicate p.

Methods

validate :: Proxy# p -> a -> Maybe RefineFailure Source #

Validate predicate p for the given a.

Nothing indicates success. Just contains a validation failure.

Instances

Instances details
Refine Fail a Source # 
Instance details

Defined in Rerefined.Predicate.Fail

Refine Succeed a Source # 
Instance details

Defined in Rerefined.Predicate.Succeed

(Refine p a, KnownPredicateName (Not p)) => Refine (Not p :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Logical.Not

Methods

validate :: Proxy# (Not p) -> a -> Maybe RefineFailure 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

(Refine l a, Refine r a, KnownPredicateName (And l r)) => Refine (And l r :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Logical.And

Methods

validate :: Proxy# (And l r) -> a -> Maybe RefineFailure Source #

(Refine l a, Refine r a, KnownPredicateName (If l r)) => Refine (If l r :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Logical.If

Methods

validate :: Proxy# (If l r) -> a -> Maybe RefineFailure Source #

(Refine l a, Refine r a, KnownPredicateName (Iff l r)) => Refine (Iff l r :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Logical.Iff

Methods

validate :: Proxy# (Iff l r) -> a -> Maybe RefineFailure Source #

(Refine l a, Refine r a, KnownPredicateName (Nand l r)) => Refine (Nand l r :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Logical.Nand

Methods

validate :: Proxy# (Nand l r) -> a -> Maybe RefineFailure Source #

(Refine l a, Refine r a, KnownPredicateName (Nor l r)) => Refine (Nor l r :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Logical.Nor

Methods

validate :: Proxy# (Nor l r) -> a -> Maybe RefineFailure Source #

(Refine l a, Refine r a, KnownPredicateName (Or l r)) => Refine (Or l r :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Logical.Or

Methods

validate :: Proxy# (Or l r) -> a -> Maybe RefineFailure Source #

(Refine l a, Refine r a, KnownPredicateName (Xor l r)) => Refine (Xor l r :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Logical.Xor

Methods

validate :: Proxy# (Xor l r) -> a -> Maybe RefineFailure Source #

(KnownNat n, Num a, Ord a, ReifyRelOp op, ReifySignedNat sign n, KnownPredicateName (CompareValue op sign n)) => Refine (CompareValue op sign n :: Type) a Source # 
Instance details

Defined in Rerefined.Predicate.Relational.Value

Methods

validate :: Proxy# (CompareValue op sign n) -> a -> Maybe RefineFailure Source #

class Predicate p => Refine1 p f where Source #

Refine functor type f with functor predicate p.

By not making the contained type accessible, we ensure refinements apply forall a. f a. That is, refinements here apply only to the functor structure, and not the stored elements.

Methods

validate1 :: Proxy# p -> f a -> Maybe RefineFailure Source #

Validate predicate p for the given f a.

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 #

data RefineFailure Source #

Predicate validation failure.

Constructors

RefineFailure 

Fields

Instances

Instances details
Show RefineFailure Source # 
Instance details

Defined in Rerefined.Predicate

class Predicate p Source #

Types which define refinements on other types.

Associated Types

type PredicateName (d :: Natural) p :: Symbol Source #

Predicate name.

Predicate names should aim to communicate the meaning of the predicate as clearly and concisely as possible.

Consider using type-level-show to build this. However, note that GHC cannot figure out KnownSymbol when there are type families in play, so you may need to put KnownSymbol constraints in instance contexts.

Instances

Instances details
Predicate Fail Source # 
Instance details

Defined in Rerefined.Predicate.Fail

Associated Types

type PredicateName d Fail :: Symbol Source #

Predicate Succeed Source # 
Instance details

Defined in Rerefined.Predicate.Succeed

Associated Types

type PredicateName d Succeed :: Symbol Source #

Predicate p => Predicate (Not p :: Type) Source #

Precendence of 9 (one below function application).

Instance details

Defined in Rerefined.Predicate.Logical.Not

Associated Types

type PredicateName d (Not p) :: Symbol 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 #

(Predicate l, Predicate r) => Predicate (And l r :: Type) Source #

Precendence of 3 (matching &&).

Instance details

Defined in Rerefined.Predicate.Logical.And

Associated Types

type PredicateName d (And l r) :: Symbol Source #

(Predicate l, Predicate r) => Predicate (If l r :: Type) Source #

Precendence of 4 (matching ==).

Instance details

Defined in Rerefined.Predicate.Logical.If

Associated Types

type PredicateName d (If l r) :: Symbol Source #

(Predicate l, Predicate r) => Predicate (Iff l r :: Type) Source #

Precendence of 4 (matching ==).

Instance details

Defined in Rerefined.Predicate.Logical.Iff

Associated Types

type PredicateName d (Iff l r) :: Symbol Source #

(Predicate l, Predicate r) => Predicate (Nand l r :: Type) Source #

Precendence of 3 (matching &&).

Instance details

Defined in Rerefined.Predicate.Logical.Nand

Associated Types

type PredicateName d (Nand l r) :: Symbol Source #

(Predicate l, Predicate r) => Predicate (Nor l r :: Type) Source #

Precendence of 2 (matching ||).

Instance details

Defined in Rerefined.Predicate.Logical.Nor

Associated Types

type PredicateName d (Nor l r) :: Symbol Source #

(Predicate l, Predicate r) => Predicate (Or l r :: Type) Source #

Precendence of 2 (matching ||).

Instance details

Defined in Rerefined.Predicate.Logical.Or

Associated Types

type PredicateName d (Or l r) :: Symbol Source #

(Predicate l, Predicate r) => Predicate (Xor l r :: Type) Source #

Precendence of 4 (matching ==).

Instance details

Defined in Rerefined.Predicate.Logical.Xor

Associated Types

type PredicateName d (Xor l r) :: Symbol Source #

Predicate (CompareValue op sign n :: Type) Source #

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

Instance details

Defined in Rerefined.Predicate.Relational.Value

Associated Types

type PredicateName d (CompareValue op sign n) :: Symbol Source #

predicateName :: forall p. (Predicate p, KnownSymbol (PredicateName 0 p)) => String Source #

Reify predicate name.