Holes in GHC

Thijs Alkemade thijsalkemade at gmail.com
Wed Jan 25 21:23:35 CET 2012

On Wed, Jan 25, 2012 at 5:50 PM, Iavor Diatchki
<iavor.diatchki at gmail.com> wrote:

> So, whenever GHC infers a type `forall a. P => t` where `a` does not
> appear in `P` or `t`, it knows that the `a` does not matter, so t
> simply defaults it to `Any`.

Okay. Thanks for your explanation. But it's still not clear to me in
which way using "Any" instead of "a" is advantageous here (unless the
goal is simply to remove the unnecessary forall from the type
signature.) But I guess what we really need: how can we indicate the
`a` is does matter to us?

> I was just wondering if you could get the same behavior by using
> `undefined`?  For example,
>    :t [undefined, ()]
>    [()]

Yes, it typechecks the same way as undefined. However, the goal is to
find the types of all the holes in the input and present them to the
user, in, for example, a learning tool. Inserting `undefined` will
make it typecheck, but gives you no information beyond that. And, as
undefined is just a function in the Prelude, it doesn't get treated in
a special way by the typechecker. So it was considered to use
`undefined` to denote a hole, but that would require a much uglier
implementation (something like checking the Name of all HsVars in
tcExpr) than extending the syntax would.

On Wed, Jan 25, 2012 at 6:37 PM, Nicolas Frisby
<nicolas.frisby at gmail.com> wrote:
> Have you considered the monomorphism restriction? For instance, does
> f () = map __ __
> exhibit the same problem when typechecked in a module?

Yes, it shows the same Any * types.

On Wed, Jan 25, 2012 at 6:10 PM, Simon Peyton-Jones
<simonpj at microsoft.com> wrote:
> are you or any of your colleagues at POPL? If so could talk in person.
> Simon


More information about the Glasgow-haskell-users mailing list