[Haskell-cafe] tokenize parser combinators and free applicatives
Ruben Astudillo
ruben.astud at gmail.com
Tue Oct 18 21:23:51 UTC 2016
On 18/10/16 18:06, Ruben Astudillo wrote:
> -- Works in wrong order
> example2 :: Either ParseError String
> example2 = parse (down query) "" "hi number 5"
> where
> query = liftAp (many letter)
> *> liftAp (many letter)
> *> liftAp (many digit)
>
I got it! I had to use the `runAp` combinator that the `free` package
offered. Changing to this version, of the function above in the previous
code, makes it work as intend. Sorry for bothering you!
example2 :: Either ParseError String
example2 = parse (runAp (\f -> f <* skipMany space) query) "" "hi
number 5"
where
query = liftAp (many letter)
*> liftAp (many letter)
*> liftAp (many digit)
--
-- Ruben
More information about the Haskell-Cafe
mailing list