[Haskell-cafe] problem with compiler error message

Dmitry Olshansky olshanskydr at gmail.com
Tue Nov 21 07:48:48 UTC 2017


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/0270e9d0/attachment.html>


More information about the Haskell-Cafe mailing list