"Found hole"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

"Found hole"

Volker Wysk-5
Hello!

What is a "hole"?

This program fails to compile:

main = _exit 0

I get this error message:

ex.hs:1:8:
    Found hole ‘_exit’ with type: t
    Where: ‘t’ is a rigid type variable bound by
               the inferred type of main :: t at ex.hs:1:1
    Relevant bindings include main :: t (bound at ex.hs:1:1)
    In the expression: _exit
    In an equation for ‘main’: main = _exit

When I replace "_exit" with "foo", it produces a "not in scope" error, as
expected. What is special about "_exit"? It doesn't occur in the Haskell
Hierarchical Libraries.

Bye
Volker

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Brandon Allbery
On Tue, Jan 20, 2015 at 1:36 PM, Volker Wysk <[hidden email]> wrote:
What is a "hole"?


When I replace "_exit" with "foo", it produces a "not in scope" error, as
expected. What is special about "_exit"? It doesn't occur in the Haskell
Hierarchical Libraries.

The leading underscore invokes the typed holes extension. If you want to use such names, you'll need {-# LANGUAGE NoTypedHoles #-} as the first line of the source file. (I am not sure why this extension was enabled by default.)

--
brandon s allbery kf8nh                               sine nomine associates
[hidden email]                                  [hidden email]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Edward Z. Yang
In reply to this post by Volker Wysk-5
Hello Volker,

All identifiers prefixed with an underscore are "typed holes",
see:
https://downloads.haskell.org/~ghc/7.8.3/docs/html/users_guide/typed-holes.html

Edward

Excerpts from Volker Wysk's message of 2015-01-20 10:36:09 -0800:

> Hello!
>
> What is a "hole"?
>
> This program fails to compile:
>
> main = _exit 0
>
> I get this error message:
>
> ex.hs:1:8:
>     Found hole ‘_exit’ with type: t
>     Where: ‘t’ is a rigid type variable bound by
>                the inferred type of main :: t at ex.hs:1:1
>     Relevant bindings include main :: t (bound at ex.hs:1:1)
>     In the expression: _exit
>     In an equation for ‘main’: main = _exit
>
> When I replace "_exit" with "foo", it produces a "not in scope" error, as
> expected. What is special about "_exit"? It doesn't occur in the Haskell
> Hierarchical Libraries.
>
> Bye
> Volker
>
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

htebalaka
In reply to this post by Volker Wysk-5
They are described at these two links: https://www.haskell.org/haskellwiki/GHC/Typed_holes https://downloads.haskell.org/~ghc/7.8.1-rc1/docs/html/users_guide/typed-holes.html

Essentially, identifiers that are not otherwise in scope and consist of an underscore or that have a trailing underscore are treated as holes, for which you wish to know which type was inferred. Previously you would need to do something like add a wrong type signature, so that the compiler would complain that the type you gave doesn't match what it inferred.

Though I get a different error message:

Found hole ‘_exit’ with type: a0 -> t
    Where: ‘a0’ is an ambiguous type variable
           ‘t’ is a rigid type variable bound by

There really should be a Num constraint as well, but at least in 7.8 it doesn't seem to include those.

Volker Wysk-5 wrote
Hello!

What is a "hole"?

This program fails to compile:

main = _exit 0

I get this error message:

ex.hs:1:8:
    Found hole ‘_exit’ with type: t
    Where: ‘t’ is a rigid type variable bound by
               the inferred type of main :: t at ex.hs:1:1
    Relevant bindings include main :: t (bound at ex.hs:1:1)
    In the expression: _exit
    In an equation for ‘main’: main = _exit

When I replace "_exit" with "foo", it produces a "not in scope" error, as
expected. What is special about "_exit"? It doesn't occur in the Haskell
Hierarchical Libraries.

Bye
Volker

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Volker Wysk-5
In reply to this post by Brandon Allbery
Hi!

Am Dienstag, 20. Januar 2015, 13:44:01 schrieben Sie:
> The leading underscore invokes the typed holes extension. If you want to
> use such names, you'll need {-# LANGUAGE NoTypedHoles #-} as the first line
> of the source file.

I get this error, when I use "{-# LANGUAGE NoTypedHoles #-}":

   ex.hs:1:14: Unsupported extension: NoTypedHoles

I'm using GHC 7.8.3. Could it be that the "NoTypedHoles" extension was added
not before 7.8.4 (the most current version).

Bye
Volker
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Alex Hammel
The only reference to a NoTypedHoles extension google can find is this thread. Odd.

On Tue, Jan 20, 2015 at 11:22 AM, Volker Wysk <[hidden email]> wrote:
Hi!

Am Dienstag, 20. Januar 2015, 13:44:01 schrieben Sie:
> The leading underscore invokes the typed holes extension. If you want to
> use such names, you'll need {-# LANGUAGE NoTypedHoles #-} as the first line
> of the source file.

I get this error, when I use "{-# LANGUAGE NoTypedHoles #-}":

   ex.hs:1:14: Unsupported extension: NoTypedHoles

I'm using GHC 7.8.3. Could it be that the "NoTypedHoles" extension was added
not before 7.8.4 (the most current version).

Bye
Volker
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Alex Hammel
You can get typed holes to compile with a warning and a runtime error with the -fdefer-type-errors flag, if that's what you want.

However, it's perfectly legal to use identifiers which look like typed holes. This works fine on 7.8.3ghc:

_exit = print
main = _exit 0

On Tue, Jan 20, 2015 at 11:25 AM, Alex Hammel <[hidden email]> wrote:
The only reference to a NoTypedHoles extension google can find is this thread. Odd.

On Tue, Jan 20, 2015 at 11:22 AM, Volker Wysk <[hidden email]> wrote:
Hi!

Am Dienstag, 20. Januar 2015, 13:44:01 schrieben Sie:
> The leading underscore invokes the typed holes extension. If you want to
> use such names, you'll need {-# LANGUAGE NoTypedHoles #-} as the first line
> of the source file.

I get this error, when I use "{-# LANGUAGE NoTypedHoles #-}":

   ex.hs:1:14: Unsupported extension: NoTypedHoles

I'm using GHC 7.8.3. Could it be that the "NoTypedHoles" extension was added
not before 7.8.4 (the most current version).

Bye
Volker
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

migmit-2
DON'T DO THAT!

Seriously, turn off compile-time type checking completely just to start an identifier with an underscore???

Отправлено с iPad

20 янв. 2015 г., в 21:39, Alex Hammel <[hidden email]> написал(а):

You can get typed holes to compile with a warning and a runtime error with the -fdefer-type-errors flag, if that's what you want.

However, it's perfectly legal to use identifiers which look like typed holes. This works fine on 7.8.3ghc:

_exit = print
main = _exit 0

On Tue, Jan 20, 2015 at 11:25 AM, Alex Hammel <[hidden email]> wrote:
The only reference to a NoTypedHoles extension google can find is this thread. Odd.

On Tue, Jan 20, 2015 at 11:22 AM, Volker Wysk <[hidden email]> wrote:
Hi!

Am Dienstag, 20. Januar 2015, 13:44:01 schrieben Sie:
> The leading underscore invokes the typed holes extension. If you want to
> use such names, you'll need {-# LANGUAGE NoTypedHoles #-} as the first line
> of the source file.

I get this error, when I use "{-# LANGUAGE NoTypedHoles #-}":

   ex.hs:1:14: Unsupported extension: NoTypedHoles

I'm using GHC 7.8.3. Could it be that the "NoTypedHoles" extension was added
not before 7.8.4 (the most current version).

Bye
Volker
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

David Feuer
Just use exit_ or something instead. Typed holes are a *really useful*
mechanism.

On Tue, Jan 20, 2015 at 3:51 PM, migmit <[hidden email]> wrote:

> DON'T DO THAT!
>
> Seriously, turn off compile-time type checking completely just to start an
> identifier with an underscore???
>
> Отправлено с iPad
>
> 20 янв. 2015 г., в 21:39, Alex Hammel <[hidden email]> написал(а):
>
> You can get typed holes to compile with a warning and a runtime error with
> the -fdefer-type-errors flag, if that's what you want.
>
> However, it's perfectly legal to use identifiers which look like typed
> holes. This works fine on 7.8.3ghc:
>
> _exit = print
> main = _exit 0
>
> On Tue, Jan 20, 2015 at 11:25 AM, Alex Hammel <[hidden email]> wrote:
>>
>> The only reference to a NoTypedHoles extension google can find is this
>> thread. Odd.
>>
>> On Tue, Jan 20, 2015 at 11:22 AM, Volker Wysk <[hidden email]>
>> wrote:
>>>
>>> Hi!
>>>
>>> Am Dienstag, 20. Januar 2015, 13:44:01 schrieben Sie:
>>> > The leading underscore invokes the typed holes extension. If you want
>>> > to
>>> > use such names, you'll need {-# LANGUAGE NoTypedHoles #-} as the first
>>> > line
>>> > of the source file.
>>>
>>> I get this error, when I use "{-# LANGUAGE NoTypedHoles #-}":
>>>
>>>    ex.hs:1:14: Unsupported extension: NoTypedHoles
>>>
>>> I'm using GHC 7.8.3. Could it be that the "NoTypedHoles" extension was
>>> added
>>> not before 7.8.4 (the most current version).
>>>
>>> Bye
>>> Volker
>>> _______________________________________________
>>> Glasgow-haskell-users mailing list
>>> [hidden email]
>>> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>>
>>
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

htebalaka
Unless it behaves differently in GHC than GHCi, you can still use underscore prefixed identifiers, provided they are in scope. I only get a type hole message if the identifier isn't defined anywhere else.

>> let _x = 2
>> _x
2
>> _y
Found hole '_y' with type: t
...
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Edward Kmett-2
In reply to this post by Volker Wysk-5
FWIW- you can think of a 'hole' as a "not in scope" error with a ton of useful information about the type such a term would have to have in order to go in the location you referenced it.

This promotes a very useful style of type-driven development that is common in Agda, where you write out your program and then leave holes that start with _'s to fill in later. 

Since no new programs are accepted or rejected, GHC turned on "holes" support by default. Users have historically faked this style with ImplicitParams by labeling their holes ?foo, but that approach doesn't give any information on what local stuff could be used to plug the hole.

The only thing that changed is the nature of the error message, which carefully track what variables are in scope, how they are instantiated, and what type the missing term is used at.

Since libraries like lens were already making heavy use of the _'d namespace this only happens if the name isn't already in use. This is why you can define _'d things just fine. The main thing that happened is if you typo the name of a lens, well, your error messages got even worse. ;)

-Edward

On Tue, Jan 20, 2015 at 1:36 PM, Volker Wysk <[hidden email]> wrote:
Hello!

What is a "hole"?

This program fails to compile:

main = _exit 0

I get this error message:

ex.hs:1:8:
    Found hole ‘_exit’ with type: t
    Where: ‘t’ is a rigid type variable bound by
               the inferred type of main :: t at ex.hs:1:1
    Relevant bindings include main :: t (bound at ex.hs:1:1)
    In the expression: _exit
    In an equation for ‘main’: main = _exit

When I replace "_exit" with "foo", it produces a "not in scope" error, as
expected. What is special about "_exit"? It doesn't occur in the Haskell
Hierarchical Libraries.

Bye
Volker

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

[solved] Re: "Found hole"

Volker Wysk-5
In reply to this post by Volker Wysk-5
Hello!

I've found what went wrong: "_exit" wasn't in scope, so it was interpreted to
be a "typed hole".

Thanks
Volker

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Merijn Verstraaten
In reply to this post by Brandon Allbery
Typed holes is not an extension, because it's considered a warning/error. The reason for this is that code with typed holes is NOT valid haskell to begin with, therefore the behaviour doesn't conflict with any description in the report.

Additionally, the ability to disable the typed holes warning is disappearing in 7.10 (well, sorta, you can silence them, but you can't get the "old" error message back). If there's any comments on how to improve the warning message to be less confusing I'd be interested to hear them.

Cheers,
Merijn

> On 20 Jan 2015, at 19:44, Brandon Allbery <[hidden email]> wrote:
>
> On Tue, Jan 20, 2015 at 1:36 PM, Volker Wysk <[hidden email]> wrote:
> What is a "hole"?
>
> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/typed-holes.html
>
> When I replace "_exit" with "foo", it produces a "not in scope" error, as
> expected. What is special about "_exit"? It doesn't occur in the Haskell
> Hierarchical Libraries.
>
> The leading underscore invokes the typed holes extension. If you want to use such names, you'll need {-# LANGUAGE NoTypedHoles #-} as the first line of the source file. (I am not sure why this extension was enabled by default.)
>
> --
> brandon s allbery kf8nh                               sine nomine associates
> [hidden email]                                  [hidden email]
> unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
> _______________________________________________
> Glasgow-haskell-users mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Volker Wysk-5
Am Mittwoch, 21. Januar 2015, 11:03:38 schrieben Sie:

> If there's any comments on how to improve the warning
> message to be less confusing I'd be interested to hear them.

What about "Found hole _foo with type: bar. This can also mean that _foo is
not in scope".

Bye
V.W.
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

David Feuer

If such verbiage is added, it should probably read more like "If you did not intend to insert a typed hole, _foo may have been misspelled."

On Jan 21, 2015 9:11 AM, "Volker Wysk" <[hidden email]> wrote:
Am Mittwoch, 21. Januar 2015, 11:03:38 schrieben Sie:

> If there's any comments on how to improve the warning
> message to be less confusing I'd be interested to hear them.

What about "Found hole _foo with type: bar. This can also mean that _foo is
not in scope".

Bye
V.W.
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Stephen Paul Weber
In reply to this post by Brandon Allbery
>The leading underscore invokes the typed holes extension. If you want to
>use such names, you'll need {-# LANGUAGE NoTypedHoles #-} as the first line
>of the source file. (I am not sure why this extension was enabled by
>default.)

This is very concening for me.  Extensions should *never* be enabled by
default!  When the TypedHoles discussion originally came up there was
definitely talk of using a switch to enable them (in fact, IIRC, they
weren't originally really quite an extension, just a compiler mode, but that
may have been a misinterpretation on my part).

Having them on by default mean that valid Haskell2010 programs might get
rejected by GHC by default, which is a pretty bad state of affairs.

--
Stephen Paul Weber, @singpolyma
See <http://singpolyma.net> for how I prefer to be contacted
edition right joseph

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Stephen Paul Weber
In reply to this post by Merijn Verstraaten
>Typed holes is not an extension, because it's considered a warning/error.
>The reason for this is that code with typed holes is NOT valid haskell to
>begin with, therefore the behaviour doesn't conflict with any description
>in the report.

Well, now I feel very silly about my last email to this list.  This is what
I understood.  I'm glad to see this is indeed the case.

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

David Feuer
In reply to this post by Stephen Paul Weber


On Jan 21, 2015 9:53 AM, "Stephen Paul Weber" <[hidden email]> wrote:

> Having them on by default mean that valid Haskell2010 programs might get rejected by GHC by default, which is a pretty bad state of affairs.

It would be if it were true. But it's not. All that changes is that you get different error messages in some cases.


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Volker Wysk-5
In reply to this post by David Feuer
Am Mittwoch, 21. Januar 2015, 09:42:05 schrieben Sie:
> If such verbiage is added, it should probably read more like "If you did
> not intend to insert a typed hole, _foo may have been misspelled."

What about "If you did not intend to insert a typed hole, _foo may have been
misspelled or out of scope." In my case, it has been out of scope, but not
misspelled.

I think verbiage is a good thing in this case.

Bye
V.W.
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: "Found hole"

Brandon Allbery
In reply to this post by Stephen Paul Weber
On Wed, Jan 21, 2015 at 9:53 AM, Stephen Paul Weber <[hidden email]> wrote:
This is very concening for me.  Extensions should *never* be enabled by default!

If you read on, you'll find that I was working from an older proposal that was never implemented. It is instead a modified version of a normal error message, and the syntax used ensures that it is always an error anyway, since it can only be invoked with either illegal expression syntax "_" or an *undefined* name "_foo").

--
brandon s allbery kf8nh                               sine nomine associates
[hidden email]                                  [hidden email]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users