Safe Haskell | Safe-Inferred |
---|
- type Delta = Double
- data Boolean f t
- class Predicate p a where
- data Const f t where
- true :: Const a ()
- data Fail f t where
- data a :|: b = a :|: b
- type :+: a b = Either a b
- data a :||: b = a :||: b
- data a ::: b = a ::: b
- data a :&: b = a :&: b
- newtype Opt a = Opt a
- data Def d a = Def d a
- 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.
Predicate HasCapture Req | |
Predicate HasCookie Req | |
Predicate HasHdr Req | |
Predicate HasQuery Req | |
Predicate HasParam Req | |
Predicate a b => Predicate (Opt a) b | |
Predicate (GetRequest a) Req | |
FromByteString a => Predicate (Capture a) Req | |
FromByteString a => Predicate (Cookie a) Req | |
FromByteString a => Predicate (Hdr a) Req | |
FromByteString a => Predicate (Query a) Req | |
FromByteString a => Predicate (Param a) Req | |
(Predicate a b, ~ * d (TVal a)) => Predicate (Def d a) b | |
(Predicate a c, Predicate b c, ~ * (FVal a) (FVal b)) => Predicate (:&: a b) c | |
(Predicate a c, Predicate b c, ~ * (FVal a) (FVal b)) => Predicate (:||: a b) c | |
(Predicate a c, Predicate b c, ~ * (TVal a) (TVal b), ~ * (FVal a) (FVal b)) => Predicate (:|: a b) c | |
Predicate (Fail f t) a | |
Predicate (Const f t) a | |
(SingI Symbol t, SingI Symbol s) => Predicate (Accept t s) Req | |
(SingI Symbol t, SingI Symbol s) => Predicate (ContentType t s) Req |
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 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 :&: b |
An Predicate
modifier which makes the underlying predicate optional,
i.e. the TVal
becomes a Maybe
and in the failure-case Nothing
is
returned.
Opt a |