list - Transform from [[Char]] to own data type in Haskell -


this question exact duplicate of:

scanl (\exp y -> scanl (\x -> if (isletter x) update exp (literal x) "" else                      if x=='+' update exp epsilon "+" else                     if x=='*' update exp epsilon "*" else                     update exp epsilon "|") y) epsilon q 

my data type is:

data reg = epsilon | literal char | or reg reg |  reg reg |  star reg  deriving eq 

and

update:: reg -> reg -> [char] -> reg  update b "" = (a `then` b) update b "|"= (a `or` b)  update b "*" = (star a)  update b "+" = (plus a) update b "?" = (opt a)   

and trying transform ["a|","bc"] (then (or b c)) using functions above , can't use parsec .

please don't "manually", end in mess. instead learn how use parser. parsec fine smaller examples, , more readable , flexible code.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -