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

**URL:** https://racket.discourse.group/t/parser-combinator-in-typed-racket-how-to-define-the-type-constructor-for-the-parser/2909
**Category:** Questions & Answers
**Tags:** typed-racket
**Created:** [May 7, 2024, 2:17pm UTC](https://racket.discourse.group/t/parser-combinator-in-typed-racket-how-to-define-the-type-constructor-for-the-parser/2909 "2024-05-07T14:17:56Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)
#### Post date: [May 7, 2024, 4:06pm UTC](https://racket.discourse.group/t/parser-combinator-in-typed-racket-how-to-define-the-type-constructor-for-the-parser/2909/2 "2024-05-07T16:06:35Z")

</div>

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:

```scheme
(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`](https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.Values%29%29) allows defining functions returning _multiple values_, which in Racket is different from functions returning pairs, lists or tuples of values.

---

_[View the full topic](https://racket.discourse.group/t/parser-combinator-in-typed-racket-how-to-define-the-type-constructor-for-the-parser/2909)._
