Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Base definitions for refinement predicates.
Synopsis
- class Predicate p => Refine p a where
- validate :: Proxy# p -> a -> Maybe RefineFailure
- class Predicate p => Refine1 p f where
- validate1 :: Proxy# p -> f a -> Maybe RefineFailure
- data RefineFailure = RefineFailure {}
- class Predicate p where
- type PredicateName (d :: Natural) p :: Symbol
- type KnownPredicateName p = KnownSymbol (PredicateName 0 p)
- predicateName :: forall p. KnownPredicateName p => String
Documentation
class Predicate p => Refine p a where Source #
Refine a
with predicate p
.
Instances
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.
Instances
(KnownNat n, Foldable f, ReifyRelOp op, KnownPredicateName (CompareLength op n)) => Refine1 (CompareLength op n :: Type) (f :: Type -> Type) Source # | Compare the length of a |
Defined in Rerefined.Predicate.Relational.Length validate1 :: forall (a :: k1). Proxy# (CompareLength op n) -> f a -> Maybe RefineFailure Source # |
data RefineFailure Source #
Predicate validation failure.
RefineFailure | |
|
Instances
Show RefineFailure Source # | |
Defined in Rerefined.Predicate showsPrec :: Int -> RefineFailure -> ShowS # show :: RefineFailure -> String # showList :: [RefineFailure] -> ShowS # |
Types which define refinements on other 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 the package type-level-show
to build this.
Instances
type KnownPredicateName p = KnownSymbol (PredicateName 0 p) Source #
Constraint for reifying a predicate name.
predicateName :: forall p. KnownPredicateName p => String Source #
Reify predicate name to a String
.
Using this regrettably necessitates UndecidableInstances
, due to the type
family in the constraint. It sucks, but that's life.