automata-0.1.0.0: automata

Safe HaskellNone
LanguageHaskell2010

Automata.Dfst

Contents

Synopsis

Static

Types

data Dfst t m Source #

A deterministic finite state transducer.

Instances
(Eq t, Eq m) => Eq (Dfst t m) Source # 
Instance details

Defined in Automata.Internal.Transducer

Methods

(==) :: Dfst t m -> Dfst t m -> Bool #

(/=) :: Dfst t m -> Dfst t m -> Bool #

(Bounded t, Enum t, Show t, Show m) => Show (Dfst t m) Source # 
Instance details

Defined in Automata.Internal.Transducer

Methods

showsPrec :: Int -> Dfst t m -> ShowS #

show :: Dfst t m -> String #

showList :: [Dfst t m] -> ShowS #

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 #

map :: Eq n => (m -> n) -> Dfst t m -> Dfst t n Source #

Map over the output tokens.

Special Transducers

rejection :: (Bounded t, Monoid m) => Dfst t m Source #

Rejects all input, producing the monoidal identity as its output.

Builder

Types

data Builder t m s a Source #

Instances
Monad (Builder t m s) Source # 
Instance details

Defined in Automata.Dfst

Methods

(>>=) :: Builder t m s a -> (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 b #

return :: a -> Builder t m s a #

fail :: String -> Builder t m s a #

Functor (Builder t m s) Source # 
Instance details

Defined in Automata.Dfst

Methods

fmap :: (a -> b) -> Builder t m s a -> Builder t m s b #

(<$) :: a -> Builder t m s b -> Builder t m s a #

Applicative (Builder t m s) Source # 
Instance details

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 #

data State s Source #

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.

transition Source #

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.

accept :: State s -> Builder t m s () Source #

Mark a state as being an accepting state.