This module defines the Ticker cofunctor, useful for 'ticking off' a prefix of the input.
- newtype Ticker x = Ticker (x -> Maybe (Ticker x))
- cofmap :: (x -> y) -> Ticker y -> Ticker x
- splitTicked :: Ticker x -> [x] -> (Ticker x, [x], [x])
- tickNone :: Ticker x
- tickOne :: Ticker x
- tickCount :: Int -> Ticker x
- tickPrefixOf :: Eq x => [x] -> Ticker x
- tickWhilePrefixOf :: [x -> Bool] -> Ticker x
- tickWhile :: (x -> Bool) -> Ticker x
- tickUntil :: (x -> Bool) -> Ticker x
- tickAll :: Ticker x
- andThen :: Ticker x -> Ticker x -> Ticker x
The Ticker type
This is a cofunctor data type for selecting a prefix of an input stream. If the next input item is acceptable, the
ticker function returns the ticker for the rest of the stream. If not, it returns
Using a Ticker
Ticker happens to be a cofunctor, but there is no standard class declaration to declare it an instance of.
Extracts a list prefix accepted by the
Ticker argument. Returns the modified ticker, the prefix, and the
remainder of the list.
Various Ticker constructors
A ticker that accepts the longest prefix of input that matches a prefix of the argument list.
A ticker that accepts a prefix of input as long as each item satisfies the predicate at the same position in the argument list. The length of the predicate list thus determines the maximum number of acepted values.
A ticker that accepts all input as long as it matches the given predicate.
A ticker that accepts all input items until one matches the given predicate.