[Haskell] Code snippet: constraint a heterogenous list by a deterministic finite automaton