[Haskell-cafe] Question, re: illegal instance error.

Andrey Chudnov achudnov at gmail.com
Tue Nov 10 16:41:43 UTC 2015


 From the Haskell 2010 report: "An instance declaration introduces an 
instance of a class. Let class cx=> C uwhere{ cbody} be a class 
declaration. The general form of the corresponding instance declaration 
is: instance cx′=> C(T u_1 … u_k )where{ d} where k ≥ 0."

Note that your instance declaration has a form C (T u1) u2.

I think adding the FlexibleInstances extension, as suggested by the 
compiler, will work. Although, depending on the context, you might need 
UndecidableInstances too.

The core problem is that the FFT class must have been defined with the 
MultiParamTypeClasses extension, which usually leads to nastiness like this.

On 11/10/2015 11:15 AM, David Banas wrote:
> Hi all,
>
> I don’t understand why this code:
>
> 50: instance (IsNat n, RealFloat a) => FFT (RTree n) a where
>
> is generating this error:
>
> fft_test.hs:50:36:
>   Illegal instance declaration for ‘FFT (RTree n) a’
>     (All instance types must be of the form (T a1 ... an)
>     where a1 ... an are *distinct type variables*,
>     and each type variable appears at most once in the instance head.
>     Use FlexibleInstances if you want to disable this.)
>   In the instance declaration for ‘FFT (RTree n) a’
>
> and was hoping someone could help me get it.
>
> Thanks!
> -db
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151110/ebc7d1db/attachment.html>


More information about the Haskell-Cafe mailing list