DFA implementation in Haskell