problem with compiler error message

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

problem with compiler error message

Dmitry Olshansky
Hello cafe!

It seems that this behavior is wrong:

> class Foo a where { type Bar a; baz :: a -> Bar a }
> baz zzz         -- zzz is not in scope
<interactive>:17:1: error:
    • Couldn't match expected type ‘Bar a’ with actual type ‘Bar a0’
      NB: ‘Bar’ is a type function, and may not be injective
      The type variable ‘a0’ is ambiguous
    • In the ambiguity check for the inferred type for ‘it’
      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
      When checking the inferred type
        it :: forall a. Bar a

As opposite - correct behavior:
> :t negate
negate :: Num a => a -> a
> negate zzz
<interactive>:19:8: error: Variable not in scope: zzz

Best regards,
Dmitry

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: problem with compiler error message

Dmitry Olshansky
GHCi 8.2.1.

2017-11-21 10:48 GMT+03:00 Dmitry Olshansky <[hidden email]>:
Hello cafe!

It seems that this behavior is wrong:

> class Foo a where { type Bar a; baz :: a -> Bar a }
> baz zzz         -- zzz is not in scope
<interactive>:17:1: error:
    • Couldn't match expected type ‘Bar a’ with actual type ‘Bar a0’
      NB: ‘Bar’ is a type function, and may not be injective
      The type variable ‘a0’ is ambiguous
    • In the ambiguity check for the inferred type for ‘it’
      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
      When checking the inferred type
        it :: forall a. Bar a

As opposite - correct behavior:
> :t negate
negate :: Num a => a -> a
> negate zzz
<interactive>:19:8: error: Variable not in scope: zzz

Best regards,
Dmitry


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: problem with compiler error message

Li-yao Xia-2
Hi Dmitry,

This is indeed a GHC bug. Here's an existing ticket about it, it seems
to be fixed for the next release of GHC.

https://ghc.haskell.org/trac/ghc/ticket/14000

Cheers,
Li-yao

On 11/21/2017 04:51 AM, Dmitry Olshansky wrote:

> GHCi 8.2.1.
>
> 2017-11-21 10:48 GMT+03:00 Dmitry Olshansky <[hidden email]>:
>
>> Hello cafe!
>>
>> It seems that this behavior is wrong:
>>
>>> class Foo a where { type Bar a; baz :: a -> Bar a }
>>> baz zzz         -- zzz is not in scope
>> <interactive>:17:1: error:
>>      • Couldn't match expected type ‘Bar a’ with actual type ‘Bar a0’
>>        NB: ‘Bar’ is a type function, and may not be injective
>>        The type variable ‘a0’ is ambiguous
>>      • In the ambiguity check for the inferred type for ‘it’
>>        To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
>>        When checking the inferred type
>>          it :: forall a. Bar a
>>
>> As opposite - correct behavior:
>>> :t negate
>> negate :: Num a => a -> a
>>> negate zzz
>> <interactive>:19:8: error: Variable not in scope: zzz
>>
>> Best regards,
>> Dmitry
>>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.