Safe Haskell | None |
---|---|
Language | Haskell2010 |
Automata.Dfst
Synopsis
- data Dfst t m
- evaluate :: (Foldable f, Ord t) => Dfst t m -> f t -> Maybe (Array m)
- evaluateAscii :: forall m. Ord m => Dfst Char m -> ByteString -> Maybe (Array m)
- union :: forall t m. (Ord t, Bounded t, Enum t, Monoid m) => Dfst t m -> Dfst t m -> Dfst t m
- map :: Eq n => (m -> n) -> Dfst t m -> Dfst t n
- rejection :: (Bounded t, Monoid m) => Dfst t m
- data Builder t m s a
- data State s
- build :: forall t m a. (Bounded t, Ord t, Enum t, Monoid m, Ord m) => (forall s. State s -> Builder t m s a) -> Dfst t m
- state :: Builder t m s (State s)
- transition :: t -> t -> m -> State s -> State s -> Builder t m s ()
- accept :: State s -> Builder t m s ()
Static
Types
A deterministic finite state transducer.
Functions
evaluate :: (Foldable f, Ord t) => Dfst t m -> f t -> Maybe (Array m) Source #
Returns Nothing
if the transducer did not end up in an
accepting state. Returns Just
if it did. The array of
output tokens always matches the length of the input.
evaluateAscii :: forall m. Ord m => Dfst Char m -> ByteString -> Maybe (Array m) Source #
union :: forall t m. (Ord t, Bounded t, Enum t, Monoid m) => Dfst t m -> Dfst t m -> Dfst t m Source #
Special Transducers
rejection :: (Bounded t, Monoid m) => Dfst t m Source #
Rejects all input, producing the monoidal identity as its output.
Builder
Types
Instances
Monad (Builder t m s) Source # | |
Functor (Builder t m s) Source # | |
Applicative (Builder t m s) Source # | |
Defined in Automata.Dfst Methods pure :: a -> Builder t m s a # (<*>) :: Builder t m s (a -> b) -> Builder t m s a -> Builder t m s b # liftA2 :: (a -> b -> c) -> Builder t m s a -> Builder t m s b -> Builder t m s c # (*>) :: Builder t m s a -> Builder t m s b -> Builder t m s b # (<*) :: Builder t m s a -> Builder t m s b -> Builder t m s a # |
Functions
build :: forall t m a. (Bounded t, Ord t, Enum t, Monoid m, Ord m) => (forall s. State s -> Builder t m s a) -> Dfst t m Source #
The argument function turns a start state into an NFST builder. This function converts the builder to a usable transducer.
state :: Builder t m s (State s) Source #
Generate a new state in the NFA. On any input, the state transitions to the start state.
Arguments
:: t | inclusive lower bound |
-> t | inclusive upper bound |
-> m | output token |
-> State s | from state |
-> State s | to state |
-> Builder t m s () |
Add a transition from one state to another when the input token is inside the inclusive range. If multiple transitions from a state are given, the last one given wins.