Hey, here is the code I try to understand but I don’t know how to consider the P here, can someone help ?
data Parser b a = P (b -> [(a, b)])
parse :: Parser b a -> b -> [(a, b)]
parse (P p) inp = p inp`
Hey, here is the code I try to understand but I don’t know how to consider the P here, can someone help ?
data Parser b a = P (b -> [(a, b)])
parse :: Parser b a -> b -> [(a, b)]
parse (P p) inp = p inp`
Like a type synonym!
P
adds nothing, but reading Parser b a
is easier on the
eyes than (b -> [(a, b)])
.
So here the “(P p) is a parser applied to inp giving " p inp`” ?
Yep! (now let me add more characters so Discourse won’t complain)