Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Rule a b = Rule {}
- type ProperRule a b = a -> Rule a b
- match :: (a -> Maybe b) -> Rule a b
- apply :: ProperRule a b -> a -> ([b], [ProperRule a b])
- arrowDimap :: (a -> b) -> (c -> d) -> (b -> c) -> a -> d
- relDimap :: (a -> b) -> (c -> d) -> Rule b c -> Rule a d
Documentation
An inference rule schema is just a curried n-ary function where n is an
unbounded, unspecified number of input premises, possibly zero (in that
case, the rule is an axiom). A Rule
element may represent three possible
situations:
- A failing computation which produces nothing; this is the degenerate case
of a rule schema that always fails to match, and also what enables to
make
Rule
an instance ofAlternative
,MonadPlus
, andMonadFail
. - A successful computation that produces a 0-ary function, i.e. an axiom;
- A successful computation that produces a unary function, that is,
a function accepting one argument and possibly returning a new
Rule
. Applying such a function to an input corresponds to "matching" the first premise of the rule schema against a candidate input. The result is either a matching failure or a new, partially applied rule.
type ProperRule a b = a -> Rule a b Source #
match :: (a -> Maybe b) -> Rule a b Source #
Constructs a single-premise rule from a matching function.
apply :: ProperRule a b -> a -> ([b], [ProperRule a b]) Source #
arrowDimap :: (a -> b) -> (c -> d) -> (b -> c) -> a -> d Source #