[Haskell-cafe] Having trouble with instance context
Antoine Latter
aslatter at gmail.com
Wed Feb 23 05:53:49 CET 2011
On Tue, Feb 22, 2011 at 8:37 PM, Kurt Stutsman <kstutsman at gmail.com> wrote:
> Ivan Lazar Miljenovic wrote:
>>
>> On 23 February 2011 13:10, Kurt Stutsman <kstutsman at gmail.com> wrote:
>>
>>>
>>> I am trying to create an instance of a class for data types deriving from
>>> Enum. When I try to specify this through a context on the instance
>>> definition, I get an error. When I do something similar with a function,
>>> it
>>> seems to work fine. Why does the instance not work?
>>>
>>
>> What's the error?
>>
>>
>
> Illegal instance declaration for `Test e'
> (All instance types must be of the form (T a1 ... an)
> where a1 ... an are type *variables*,
> and each type variable appears at most once in the instance head.
> Use -XFlexibleInstances if you want to disable this.)
> In the instance declaration for `Test e'
>
As the error says, compiling with the flag '-XFlexibleInstances' will
make the message go away.
You can also add a language pragma to the top of your source file:
{-# LANGUAGE FlexibleInstances #-}
Antoine
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list