module Haskell13 where
import DFA
{-
Replace all the ... with the appropriate expressions corresponding to your
solution. You can work on one problem at a time, and try to compile, by encosling
the rest of the assignment in "{- ... -}" to comment it out.
-}
delPrefix0 :: DFA st -> DFA st
delPrefix0 (DFA (states,alpha,delta,start,isFinal)) =
(DFA (states1,alpha,delta1,start1,isFinal1)) where
states1 = ...
delta1 q x = ...
start1 = ...
isFinal1 q = ...
{-
You can add new states to a (DFA st) using states of type (Either st new)
Values of type (Either st new) are written as
- (Left q) for any q of type st, or
- (Right q) for any q of type new.
This allows you to use values of both types without confusing them.
Below we use states of type (Either st Int) so you can add as many
new states (Right 0, Right 1, etc.) as you want.
-}
addPrefix0 :: DFA st -> DFA (Either st Int)
addPrefix0 (DFA (states,alpha,delta,start,isFinal)) =
(DFA (states1,alpha,delta1,start1,isFinal1)) where
states1 = ...
delta1 q1 x = case q1 of
Left q -> ...
Right n -> ...
start1 = ...
isFinal1 q1 = case q1 of
Left q -> ...
Right n -> ...