| Copyright | (c) Roman Cheplyaka |
|---|---|
| License | MIT |
| Maintainer | Roman Cheplyaka <roma@ro-che.info> |
| Stability | experimental |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Text.Regex.Applicative.Object
Description
This is a low-level interface to the regex engine.
Synopsis
- data ReObject s r
- compile :: RE s r -> ReObject s r
- emptyObject :: ReObject s r
- data Thread s r
- threads :: ReObject s r -> [Thread s r]
- failed :: ReObject s r -> Bool
- isResult :: Thread s r -> Bool
- getResult :: Thread s r -> Maybe r
- results :: ReObject s r -> [r]
- data ThreadId
- threadId :: Thread s r -> Maybe ThreadId
- step :: s -> ReObject s r -> ReObject s r
- stepThread :: s -> Thread s r -> [Thread s r]
- fromThreads :: [Thread s r] -> ReObject s r
- addThread :: Thread s r -> ReObject s r -> ReObject s r
Documentation
The state of the engine is represented as a "regex object" of type
, where ReObject s rs is the type of symbols and r is the
result type (as in the RE type). Think of ReObject as a collection of
Threads ordered by priority. E.g. threads generated by the left part of
<|> come before the threads generated by the right part.
emptyObject :: ReObject s r #
Empty object (with no threads)
A thread either is a result or corresponds to a symbol in the regular expression, which is expected by that thread.
threads :: ReObject s r -> [Thread s r] #
List of all threads of an object. Each non-result thread has a unique id.
failed :: ReObject s r -> Bool #
Check if the object has no threads. In that case it never will
produce any new threads as a result of step.
getResult :: Thread s r -> Maybe r #
Return the result of a result thread, or Nothing if it's not a result
thread
stepThread :: s -> Thread s r -> [Thread s r] #
Feed a symbol into a non-result thread. It is an error to call stepThread
on a result thread.
fromThreads :: [Thread s r] -> ReObject s r #
Create an object from a list of threads. It is recommended that all
threads come from the same ReObject, unless you know what you're doing.
However, it should be safe to filter out or rearrange threads.