Misunderstanding Types


#1

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`

#2

Like a type synonym!

P adds nothing, but reading Parser b a is easier on the
eyes than (b -> [(a, b)]).


#3

So here the “(P p) is a parser applied to inp giving " p inp`” ?


#4

Yep! (now let me add more characters so Discourse won’t complain)