[Haskell-cafe] Regular Expression to Determinate Finite Automata translator

Felipe Lessa felipe.lessa at gmail.com
Thu Jul 22 16:01:43 EDT 2010

Some comments:

- You can run your code thru HLint, here it gives me 27 suggestions.

- Why don't you derive the Show instance for RE instead of writing it
by yourself?

- Note that

  do x
     do y

is the same as

  do x

- You can parametrize RE as

  data RE s p = Epsilon
              | Leaf Char s p
              | Selection (RE s p) (RE s p)
              | Sequence  (RE s p) (RE s p)
              | Kleene    (RE s p)
              | Optional  (RE s p)
              | End s
              deriving (Show)

  type RE1 = RE () ()
  type RE2 = RE State ()
  type RE3 = RE State Pos

Cheers! =)


More information about the Haskell-Cafe mailing list