-- isString.hs: functions implementing the fsm in string-fsm.jpeg (this folder) -- The 'isString :: String -> Bool' line declares isString to be a function which takes -- a Haskell string and returns true if that string matches the FSM. isString :: String -> Bool isString chars = isStringStart chars isStringStart text = if null text then False else if (head text) == 'Q' then isStringMiddle (tail text) else False isStringMiddle text = if null text then False else let next:rest = text in if next == 'a' then isStringMiddle rest else if next == 'Q' then isDone rest else if next == 'B' then isEscape rest else False isEscape text = if null text then False else if (head text) == 'Q' then isStringMiddle (tail text) else False isDone text = null text