[Haskell-cafe] problem with compiler error message

Dmitry Olshansky olshanskydr at gmail.com
Tue Nov 21 09:51:27 UTC 2017


GHCi 8.2.1.

2017-11-21 10:48 GMT+03:00 Dmitry Olshansky <olshanskydr at gmail.com>:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20171121/a85a45d1/attachment.html>


More information about the Haskell-Cafe mailing list