[Haskell-cafe] type variable is ambiguous in a non-injective type family

Anthony Clayden anthony_clayden at clear.net.nz
Mon Jul 29 06:07:14 UTC 2019


> I really don't understand what is going on here.  ...

--------------------------------------------------------------------------------

> {-# LANGUAGE TypeFamilies #-}
> {-# LANGUAGE AllowAmbiguousTypes #-}


> {-
>
> src/Games/Ambiguous.hs:15:16: error: …
>    • Couldn't match expected type ‘SubAmbi a0’
>                  with actual type ‘SubAmbi a’
>      NB: ‘SubAmbi’ is a non-injective type family
>      The type variable ‘a0’ is ambiguous
>
> -}

Hi Henry, both replies you've received are excellent, I won't expand on them.

I am interested in how you got into such a pickle in the first place:

Why set `AllowAmbiguousTypes`? Did you understand what that means?

Did you think it odd that despite having that set, you get error `type
variable ... is ambiguous`?

There are ways to achieve what you want without `AllowAmbiguousTypes`
nor `TypeApplications`, but that would need a rather different design.
So what lead you into this design?

AntC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190729/9327a484/attachment.html>


More information about the Haskell-Cafe mailing list