Safe Haskell | Safe-Inferred |
---|
- type Delta = Double
- data Boolean f t
- class Predicate p a where
- data a :|: b = a :|: b
- data a :&: b = a :&: b
- data a :||: b = a :||: b
- data a ::: b = a ::: b
- type :+: a b = Either a b
- data Const f t
- data Fail f t
- data Opt a
- data Def d a
- data PMap a f t
- data PMapT a t
- data PMapF a f
- constant :: t -> Const f t
- failure :: f -> Fail f t
- true :: Const a ()
- opt :: a -> Opt a
- def :: d -> a -> Def d a
- pmap :: (Boolean (FVal a) (TVal a) -> Boolean f t) -> a -> PMap a f t
- pmapT :: (TVal a -> Boolean (FVal a) t) -> a -> PMapT a t
- pmapF :: (FVal a -> Boolean f (TVal a)) -> a -> PMapF a f
- with :: (Monad m, Predicate p a) => p -> a -> (TVal p -> m ()) -> m ()
Documentation
Delta
is a measure of distance. It is (optionally)
used in predicates that evaluate to T
but not uniquely so, i.e.
different evaluations of T
are possible and they may have a different
"fitness".
An example is content-negotiation. A HTTP request may specify
a preference list of various media-types. A predicate matching one
specific media-type evaluates to T
, but other media-types may match
even better. To represent this ambivalence, the predicate will include
a delta value which can be used to decide which of the matching
predicates should be preferred.
class Predicate p a whereSource
The Predicate
class declares the function apply
which
evaluates the predicate against some value, returning a value
of type Boolean
.
Besides being parameterised over predicate type and predicate
parameter, the class is also parameterised over the actual types
of T's and F's meta-data.
A Predicate
instance corresponding to the logical
OR connective of two Predicate
s. It requires the
meta-data of each T
rue branch to be of the same type.
If both arguments evaluate to T
the one with the
smaller Delta
will be preferred, or--if equal--the
left-hand argument.
a :|: b |
a :&: b |
A Predicate
instance corresponding to the logical
OR connective of two Predicate
s. The meta-data of
each T
rue branch can be of different types.
If both arguments evaluate to T
the one with the
smaller Delta
will be preferred, or--if equal--the
left-hand argument.
a :||: b |
A Predicate
function, i.e. a function of the underlying predicate's
result.