
My impression is that earlier [] == [] used to give a type error. Now it gives True. So 1. Which instance of == is being used? 2. Is there some option controlling this behavior?

This looks like a great opportunity to try out the new holes functionality:
[Prelude] λ [] == _what
<interactive>:3:7:
Found hole ‘_what’ with type: [t0]
Where: ‘t0’ is an ambiguous type variable
Relevant bindings include it :: Bool (bound at <interactive>:3:1)
In the second argument of ‘(==)’, namely ‘_what’
In the expression: [] == _what
In an equation for ‘it’: it = [] == _what
Looks like it defaults to [Bool]!
Correct me if I'm wrong :)
- Lyndon
On Tue, Mar 10, 2015 at 1:33 PM, Rustom Mody
My impression is that earlier [] == [] used to give a type error. Now it gives True.
So 1. Which instance of == is being used? 2. Is there some option controlling this behavior?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

On Tue, Mar 10, 2015 at 8:07 AM, Lyndon Maydwell
This looks like a great opportunity to try out the new holes functionality:
[Prelude] λ [] == _what
<interactive>:3:7: Found hole ‘_what’ with type: [t0] Where: ‘t0’ is an ambiguous type variable Relevant bindings include it :: Bool (bound at <interactive>:3:1) In the second argument of ‘(==)’, namely ‘_what’ In the expression: [] == _what In an equation for ‘it’: it = [] == _what
Looks like it defaults to [Bool]!
Correct me if I'm wrong :)
Thanks Lyndon. But on my (debian testing) ghc I get: Prelude> [] == _what <interactive>:2:7: Not in scope: `_what' [ghc 7.6.3] And my main question is the second one : For pedagogic purposes I want to get the error -- Whats the (family of) related options?

And my main question is the second one : For pedagogic purposes I want to get the error -- Whats the (family of) related options?
This feature is called "type holes" introduced by GHC 7.8.1.
see https://wiki.haskell.org/GHC/Typed_holes in details.
2015-03-10 11:42 GMT+09:00 Rustom Mody
On Tue, Mar 10, 2015 at 8:07 AM, Lyndon Maydwell
wrote: This looks like a great opportunity to try out the new holes functionality:
[Prelude] λ [] == _what
<interactive>:3:7: Found hole ‘_what’ with type: [t0] Where: ‘t0’ is an ambiguous type variable Relevant bindings include it :: Bool (bound at <interactive>:3:1) In the second argument of ‘(==)’, namely ‘_what’ In the expression: [] == _what In an equation for ‘it’: it = [] == _what
Looks like it defaults to [Bool]!
Correct me if I'm wrong :)
Thanks Lyndon. But on my (debian testing) ghc I get:
Prelude> [] == _what
<interactive>:2:7: Not in scope: `_what'
[ghc 7.6.3]
And my main question is the second one : For pedagogic purposes I want to get the error -- Whats the (family of) related options?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- 山本悠滋 twitter: @igrep Facebook: http://www.facebook.com/igrep Google+: https://plus.google.com/u/0/+YujiYamamoto_igrep

GHC 7.8.3 here.
Hmm, on second inspection I believe that the Bool reference is to the
top-level expression, not the list items after all.
I don't seem to get any defaulting behaviour either when not using GHCi.
This seems to indicate that the extended interactive type defaulting is
coming into play:
https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_guide/interactive-e...
I'd guess that this means that the () default is being used. -Wall seems to
indicate that this is in-fact the case:
[Prelude] λ [] == []
<interactive>:2:4: Warning:
Defaulting the following constraint(s) to type ‘()’
(Eq t0) arising from a use of ‘==’
In the expression: [] == []
In an equation for ‘it’: it = [] == []
True
Hope this helps.
- Lyndon
On Tue, Mar 10, 2015 at 1:42 PM, Rustom Mody
On Tue, Mar 10, 2015 at 8:07 AM, Lyndon Maydwell
wrote: This looks like a great opportunity to try out the new holes functionality:
[Prelude] λ [] == _what
<interactive>:3:7: Found hole ‘_what’ with type: [t0] Where: ‘t0’ is an ambiguous type variable Relevant bindings include it :: Bool (bound at <interactive>:3:1) In the second argument of ‘(==)’, namely ‘_what’ In the expression: [] == _what In an equation for ‘it’: it = [] == _what
Looks like it defaults to [Bool]!
Correct me if I'm wrong :)
Thanks Lyndon. But on my (debian testing) ghc I get:
Prelude> [] == _what
<interactive>:2:7: Not in scope: `_what'
[ghc 7.6.3]
And my main question is the second one : For pedagogic purposes I want to get the error -- Whats the (family of) related options?

On Tue, Mar 10, 2015 at 8:21 AM, Lyndon Maydwell
GHC 7.8.3 here.
Hmm, on second inspection I believe that the Bool reference is to the top-level expression, not the list items after all.
I don't seem to get any defaulting behaviour either when not using GHCi. This seems to indicate that the extended interactive type defaulting is coming into play:
https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_guide/interactive-e...
I'd guess that this means that the () default is being used. -Wall seems to indicate that this is in-fact the case:
[Prelude] λ [] == []
<interactive>:2:4: Warning: Defaulting the following constraint(s) to type ‘()’ (Eq t0) arising from a use of ‘==’ In the expression: [] == [] In an equation for ‘it’: it = [] == [] True
Hope this helps.
Thats better -- thanks Lyndon! So after some fishing around I find the more pointed warning I am after is -fwarn-type-defaults The docs seem confusing though: https://downloads.haskell.org/~ghc/7.4.1/docs/html/users_guide/options-sanit... Under -fwarn-type-defaults: says *Have the compiler warn/inform you where in your source the Haskell defaulting mechanism for numeric types kicks in.* Wheres the numeric here?

On Mon, Mar 9, 2015 at 8:20 PM, Rustom Mody
Under -fwarn-type-defaults: says
*Have the compiler warn/inform you where in your source the Haskell defaulting mechanism for numeric types kicks in.*
Wheres the numeric here?
In GHCi, the type defaulting mechanism is extended beyond numerics. See https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_guide/interactive-e... . In this case, the list is defaulting to type [()].

On Mon, Mar 9, 2015 at 10:33 PM, Rustom Mody
My impression is that earlier [] == [] used to give a type error. Now it gives True.
So 1. Which instance of == is being used? 2. Is there some option controlling this behavior?
The instance being used is (), and it's controlled by -XExtendedDefaultRules. https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/interactive-... -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Tue, Mar 10, 2015 at 2:03 PM, Brandon Allbery
On Mon, Mar 9, 2015 at 10:33 PM, Rustom Mody
wrote: My impression is that earlier [] == [] used to give a type error. Now it gives True.
So 1. Which instance of == is being used? 2. Is there some option controlling this behavior?
The instance being used is (), and it's controlled by -XExtendedDefaultRules.
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/interactive-...
Thats what I first thought Tried starting ghci with -XNoExtendedDefaultRules but it does not turn it off

On Tue, Mar 10, 2015 at 9:18 AM, Rustom Mody
On Tue, Mar 10, 2015 at 2:03 PM, Brandon Allbery
wrote: On Mon, Mar 9, 2015 at 10:33 PM, Rustom Mody
wrote: 1. Which instance of == is being used? 2. Is there some option controlling this behavior?
The instance being used is (), and it's controlled by -XExtendedDefaultRules.
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/interactive-...
Thats what I first thought Tried starting ghci with -XNoExtendedDefaultRules but it does not turn it off
Looks like -X only affects compiler flags: Prelude> :showi language base language is: Haskell2010 with the following modifiers: -XNoMonomorphismRestriction -XNoDatatypeContexts -XNondecreasingIndentation -XExtendedDefaultRules Probably need to use :seti inside of ghci, or in a .ghci / ghci.ini file. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Tue, Mar 10, 2015 at 6:54 PM, Brandon Allbery
On Tue, Mar 10, 2015 at 9:18 AM, Rustom Mody
wrote: On Tue, Mar 10, 2015 at 2:03 PM, Brandon Allbery
wrote: On Mon, Mar 9, 2015 at 10:33 PM, Rustom Mody
wrote: 1. Which instance of == is being used? 2. Is there some option controlling this behavior?
The instance being used is (), and it's controlled by -XExtendedDefaultRules.
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/interactive-...
Thats what I first thought Tried starting ghci with -XNoExtendedDefaultRules but it does not turn it off
Looks like -X only affects compiler flags:
Prelude> :showi language base language is: Haskell2010 with the following modifiers: -XNoMonomorphismRestriction -XNoDatatypeContexts -XNondecreasingIndentation -XExtendedDefaultRules
Probably need to use :seti inside of ghci, or in a .ghci / ghci.ini file.
Ok that did it -- Thanks Brandon. Also thanks Taylor for the exact pointer to the divergence between ghc and ghci semantics
participants (5)
-
Brandon Allbery
-
Lyndon Maydwell
-
Rustom Mody
-
Taylor Hedberg
-
Yuji Yamamoto