Safe Haskell | Safe-Infered |
---|
Representation of DFAs and some simple algorithms on them.
- data DFA
- type Label = CUInt
- type State = CUInt
- initialize :: Bool -> State -> IO DFA
- finished :: DFA -> IO ()
- addTransition :: DFA -> (State, Label, State) -> IO ()
- setFinal :: DFA -> State -> IO ()
- minimize :: DFA -> Bool -> IO ()
- foldTransitions :: DFA -> ((State, Label, State, Bool) -> b -> IO b) -> b -> IO b
- getInitialState :: DFA -> IO State
- numStates :: DFA -> IO CUInt
- numSymbols :: DFA -> IO CUInt
- isFinal :: DFA -> State -> IO Bool
- debugging :: DFA -> IO Bool
- loadFromFile :: FilePath -> IO DFA
- dumpToFile :: DFA -> FilePath -> IO ()
Documentation
Initialisation
Construction
addTransition :: DFA -> (State, Label, State) -> IO ()Source
Add a transition from the given State
on the given Label
to
the given State
to DFA
.
setFinal :: DFA -> State -> IO ()Source
Set the final bit associated with State
.
The minimization algorithm will distinguish states with different bits (that are otherwise bisimilar).
Reduce the DFA
using Antti Valmari's algorithm. The result
should be the same as for the standard algorithm due to Hopcroft.
Traversal
foldTransitions :: DFA -> ((State, Label, State, Bool) -> b -> IO b) -> b -> IO bSource
Traverse the transitions of DFA
by invoking the given function
on each of them.
DFAs aren't functorial (they're monomorphic), so we cannot use
Traversable
.
Inspection
getInitialState :: DFA -> IO StateSource
Get the initial state.
numSymbols :: DFA -> IO CUIntSource
Returns the number of symbols that are actually present in DFA
.
loadFromFile :: FilePath -> IO DFASource
Load a DFA
from a file in a standard format. (See the accompanying examples and dfa.c
for details.)