[Haskell-cafe] Parsec question

Jason Dusek jason.dusek at gmail.com
Fri Apr 17 06:55:54 EDT 2009


2009/04/17 minh thu <noteed at gmail.com>:
> 2009/04/17 Michael Mossey <mpm at alumni.caltech.edu>:
>> I wonder how I can get the manyTill to be happy with eof
>> before finding the //? I tried
>>
>> parseText = manyTill anyChar (try (string "//") <|> eof)
>>
>> but got a type error.
>
> You can use 'notFollowedBy' [...]

  You get a type error because `string "//"` parses to a
  `String` while `eof` parses to a `()`. Instead you might use:

    parseText = manyTill anyChar (try (string "//" >> return ()) <|> eof)

--
Jason Dusek


More information about the Haskell-Cafe mailing list