## TypeHoles: unbound variables as named holes

2012-10-05 14:22:06 GMT

There is also the small matter, in this example, of distinguishing which `_' is which. The description works, but you have to think about it. I don't have an immediate and simple solution to this. Perhaps the addition of unique labels (e.g. _$1 _$2). But this is not a major problem. It can even wait until some future development/expansion on TypeHoles.

I have a proposal. Someone has already suggested on hackage.haskell.org/trac/ghc/ticket/5910 that an un-bound variable behaves like a hole. Thus, if you say

f x = y

GHC says “Error: y is not in scope”. But (idea) with -XTypeHoles

f x = y

might generate

1. (renamer) Warning: y is not in scope

2. (type) Error: Hole “y” has type....

So that’s like a named hole, in effect.

If you say

f x = 4

GHC warns about the unused binding for x. But if you say

f _x = 4

the unused-binding warning is suppressed. So (idea) if you say

f x = _y

maybe we can suppress warning (1). And, voila, named holes.

Moreover if you add –fdefer-type-errors you can keep going and run the program.

Any comments? This is pretty easy to do.

* Roman Cheplyaka [2012-10-05 10:22:23+0300]Ah, I see. Since `c` is universally quantified, it means different> * Simon Peyton-Jones [2012-10-05 07:14:36+0000]

> > | Sounds cool. I would also expect that if you have several occurences of

> > | the same unbound identifier, then it gets a unified type.

> >

> > I thought about this, but I think not. Consider

> >

> > f x1 = _y

> > g x2 = _y

> >

> > Do you want _y and _y to be unified, so that f and g are no longer polymorphic? I think not. Any more than the "_" holes we have now are unified.

>

> Do you mean polymorphism in their argument? Why would it go away?

>

> I would expect the functions to get types `a -> c` and `b -> c`

> respectively, and `c` to be reported as the type of the hole.

things for f and g. Good point.

_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users <at> haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users