interact package:yi
This is a library of interactive processes combinators, usable to
define extensible keymaps.
(Inspired by the Parsec library, written by Koen Claessen)
The processes are:
- composable: in parallel using <|>, in sequence using
monadic bind.
- extensible: it is always possible to override a behaviour by
combination of adjustPriority and <|>. (See also
<|| for a convenient combination of the two.)
- monadic: sequencing is done via monadic bind. (leveraging the
whole battery of monadic tools that Haskell provides)
The processes can parse input, and write output that depends on it.
The semantics are quite obvious; only disjunction deserve a bit more
explanation:
in
p = (a <|> b), what happens if
a and
b recognize the same input (prefix), but produce conflicting
output?
- if the output is the same (as by the Eq class), then the processes
(prefixes) are "merged"
- if a Write is more prioritized than the other, the one with low
priority will be discarded
- otherwise, the output will be delayed until one of the branches
can be discarded.
- if there is no way to disambiguate, then no output will be
generated anymore. This situation can be detected by using
possibleActions however.
TODO: we're just converting back and forth here,
historyMoveGen
and friends need to migrate to YiString it seems.
Abstraction of the automaton state.
Collection of
Modes for working with Haskell.
Abstraction of monadic interactive processes