[Haskell-cafe] [] == []

Lyndon Maydwell maydwell at gmail.com
Tue Mar 10 02:51:36 UTC 2015


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-evaluation.html

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 <rustompmody at gmail.com> wrote:

>
>
> On Tue, Mar 10, 2015 at 8:07 AM, Lyndon Maydwell <maydwell at gmail.com>
> 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?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150310/c5207fce/attachment.html>


More information about the Haskell-Cafe mailing list