Parser combinator in Typed Racket: how to define the type constructor for the parser?

Hi @yossarian,

After a very quick first look I think you should not use Values in this context, but rather Pairof or List. Both of the following typecheck:

(struct (a) Parser ([parse : (-> String (Listof (Pairof a String)))]))
(struct (a) Parser ([parse : (-> String (Listof (List a String)))]))

The first type is the exact translation of the type in Haskell. For various reasons using a List may sometimes be preferable, but I suggest you go with Pairof until you find a definite advantage to using List.

Values allows defining functions returning multiple values, which in Racket is different from functions returning pairs, lists or tuples of values.

1 Like