Visualize the automata using GraphViz

This commit is contained in:
Joscha 2019-10-26 18:18:08 +00:00
parent 34a3a2027c
commit 10db66edc0
5 changed files with 98 additions and 2 deletions

View file

@ -9,6 +9,7 @@ module Rextra.Dfa (
-- ** Properties
, stateMap
, entryState
, exitStates
-- ** Executing
, transition
, execute
@ -34,6 +35,13 @@ data Dfa s t = Dfa
getState :: (Ord s) => Dfa s t -> s -> State s t
getState dfa s = stateMap dfa Map.! s
exitStates :: (Ord s) => Dfa s t -> Set.Set s
exitStates dfa = Set.fromList
. map fst
. filter (accepting . snd)
. Map.assocs
$ stateMap dfa
data State s t = State
{ transitions :: Map.Map t s
, defaultTransition :: s