Search code examples
haskellparsec

parsec: combine two char parsers into a string


I am trying to write a parser that glues two characters into a string:

(<:>) = liftM2 (\a b -> [a, b])
mychar :: Parser String
mychar = (char '\\') <:> (noneOf "u")

is it possible to make it more elegant? I am a newbie. Please help.


Solution

  • Another choice is:

    mychar = sequence [char '\\', noneof "u"]