On 2015-07-30 at 21:39, Michael Karg <[email protected]> wrote:
> I guess without that pragma, the string literals already imply t ~ [] for
> Foldable t.
You're basically right. Without OverloadedStrings, a string literal
("foo") is always a String. With OverloadedStrings, it's free to be
any t such that IsString t. (But it's expected to have a monomorphic
type, not the polymorphic "foo" :: forall t. IsString t => t)
Hence the second error below - GHC tries to pick a type that is both
Foldable and IsString, but that's not a unique combination.
>> GHC 7.10 fails with the following errors (whereas 7.8 compiles without
>> complaining):
>>
>>
>> ghc --make "Testcase.hs"
>> [1 of 1] Compiling Main ( Testcase.hs, Testcase.o )
>> Testcase.hs:7:31:
>> No instance for (Foldable t0) arising from a use of ‘elem’
>> The type variable ‘t0’ is ambiguous
>> (...)
>>
>> Testcase.hs:8:15:
>> No instance for (Data.String.IsString (t0 Char))
>> arising from the literal ‘"$_-"’
>> The type variable ‘t0’ is ambiguous
>> (...)
Question for GHC devs:
How hard would it be to give a different error message instead of "No
instance ..." when the type variable is ambiguous? I always find this
error slightly misleading, since it seems to me that there are multiple
valid instances, not that there is "no instance".
bergey
_______________________________________________
ghc-devs mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs