Make constructing NFAs and DFAs more usable

This commit is contained in:
Joscha 2019-10-26 10:12:35 +00:00
parent 02bf60b095
commit c44f4c090b
2 changed files with 20 additions and 5 deletions

View file

@ -56,8 +56,10 @@ dfa stateMap entryState =
let myDfa = Dfa{stateMap=stateMap, entryState=entryState}
in if integrityCheck myDfa then Just myDfa else Nothing
dfa' :: (Ord s) => [(s, State s t)] -> s -> Maybe (Dfa s t)
dfa' states entryState = dfa (Map.fromList states) entryState
dfa' :: (Ord s, Ord t) => [(s, [(t, s)], s, Bool)] -> s -> Maybe (Dfa s t)
dfa' states entryState =
let stateList = map (\(s, ts, dt, a) -> (s, State (Map.fromList ts) dt a)) states
in dfa (Map.fromList stateList) entryState
{-
- Executing