
5 Oct
2016
5 Oct
'16
12:15 p.m.
On 2016-10-05 08:32 AM, Lian Hung Hon wrote:
Given
data Expression = ExpToken String | ExpAnd Expression Expression
How to write an attoparsec parser that parses this example:
"a" and "b" and "c"
into
ExpAnd (ExpToken "a") (ExpAnd (ExpToken "b") (ExpToken "c"))?
Consider using sepBy1 to obtain ["a", "b", "c"] first. Then you're just a foldr away.