[Haskell-cafe] Flexible instances
Henning Thielemann
schlepptop at henning-thielemann.de
Wed Oct 15 17:14:48 EDT 2008
George Pollard schrieb:
> I'm a little confused. Why is this allowed:
>
>> data Blah = Blah
>>
>> instance Eq Blah where
>> x == y = True
>
> But not this:
>
>> class Stringable a where
>> toString :: a -> String
>>
>> instance Stringable [Char] where
>> toString = id
>
> (Resulting in:)
>
>> Illegal instance declaration for `Stringable [Char]'
>> (All instance types must be of the form (T a1 ... an)
>> where a1 ... an are distinct type *variables*
>> Use -XFlexibleInstances if you want to disable this.)
>> In the instance declaration for `Stringable [Char]'
>
> 'Blah' isn't a type variable, is it? Is my brain just not working right
> today?
http://www.haskell.org/haskellwiki/List_instance
More information about the Haskell-Cafe
mailing list