Read Instance for UArray won't port to linux

I have the pleasure of porting a good sized Haskell application to linux. So far the Haskell code has compiled without incident, however some code that I hacked to implement a Read instance for Unboxed Arrays does not compile on linux even though it compiles just fine on Windows XP in Haskell 6.6. The code reads as, instance Read (UArray Int Double) where readsPrec p = readParen (p > 9) (\r -> [(array b as :: UArray Int Double, u) | ("array",s) <- lex r, (b,t) <- reads s, (as,u) <- reads t ]) The error in linux is: Illegal instance declaration for `Read (UArray Int Double)' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Read (UArray Int Double)' Why does it want three parameters for the instance type? I am baffled by this. -- View this message in context: http://www.nabble.com/Read-Instance-for-UArray-won%27t-port-to-linux-tf34002... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

It looks like you forgot to pass a compiler flag, namely -fglasgow-exts.
Cheers,
Spencer Janssen
On Tue, 13 Mar 2007 22:20:20 -0700 (PDT)
SevenThunders
I have the pleasure of porting a good sized Haskell application to linux. So far the Haskell code has compiled without incident, however some code that I hacked to implement a Read instance for Unboxed Arrays does not compile on linux even though it compiles just fine on Windows XP in Haskell 6.6.
The code reads as,
instance Read (UArray Int Double) where readsPrec p = readParen (p > 9) (\r -> [(array b as :: UArray Int Double, u) | ("array",s) <- lex r, (b,t) <- reads s, (as,u) <- reads t ])
The error in linux is: Illegal instance declaration for `Read (UArray Int Double)' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Read (UArray Int Double)'
Why does it want three parameters for the instance type? I am baffled by this.

You guys are awesome! I post this not 12 hours ago and I already have a complete treatise on the subject. Yeah to clarify things putting an ellipsis between b and c would help. But also clarify the meaning of distinct type variables. Does this mean the type variable must not be parameterized? I ran into this because I decided during my port that I would try to learn some of the better build tools on linux. So now I'm acquainted with Cmake, which is a great tool and cabal which is also very impressive. My problem boiled down to the fact that I didn't know how to set the correct compiler flags within cabal. I figured out the FFI flags and now I suppose the gch extensions can be set with Ghc-options: -fglasgow-exts in my .cabal file. Is there a type in the Extensions field that corresponds to this? Spencer Janssen-2 wrote:
It looks like you forgot to pass a compiler flag, namely -fglasgow-exts.
Cheers, Spencer Janssen
On Tue, 13 Mar 2007 22:20:20 -0700 (PDT) SevenThunders
wrote: I have the pleasure of porting a good sized Haskell application to linux. So far the Haskell code has compiled without incident, however some code that I hacked to implement a Read instance for Unboxed Arrays does not compile on linux even though it compiles just fine on Windows XP in Haskell 6.6.
The code reads as,
instance Read (UArray Int Double) where readsPrec p = readParen (p > 9) (\r -> [(array b as :: UArray Int Double, u) | ("array",s) <- lex r, (b,t) <- reads s, (as,u) <- reads t ])
The error in linux is: Illegal instance declaration for `Read (UArray Int Double)' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Read (UArray Int Double)'
Why does it want three parameters for the instance type? I am baffled by this.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- View this message in context: http://www.nabble.com/Read-Instance-for-UArray-won%27t-port-to-linux-tf34002... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

Hello SevenThunders, Wednesday, March 14, 2007, 10:32:23 PM, you wrote: the type variables are dark side of GHC, and you need to have at least 1 mlOleg of brain to understand them. it will be great if someone will ever write reasonable introduction into this. meanwhile, you can look into ghc docs
You guys are awesome! I post this not 12 hours ago and I already have a complete treatise on the subject. Yeah to clarify things putting an ellipsis between b and c would help. But also clarify the meaning of distinct type variables. Does this mean the type variable must not be parameterized?
I ran into this because I decided during my port that I would try to learn some of the better build tools on linux. So now I'm acquainted with Cmake, which is a great tool and cabal which is also very impressive. My problem boiled down to the fact that I didn't know how to set the correct compiler flags within cabal. I figured out the FFI flags and now I suppose the gch extensions can be set with Ghc-options: -fglasgow-exts in my .cabal file. Is there a type in the Extensions field that corresponds to this?
Spencer Janssen-2 wrote:
It looks like you forgot to pass a compiler flag, namely -fglasgow-exts.
Cheers, Spencer Janssen
On Tue, 13 Mar 2007 22:20:20 -0700 (PDT) SevenThunders
wrote: I have the pleasure of porting a good sized Haskell application to linux. So far the Haskell code has compiled without incident, however some code that I hacked to implement a Read instance for Unboxed Arrays does not compile on linux even though it compiles just fine on Windows XP in Haskell 6.6.
The code reads as,
instance Read (UArray Int Double) where readsPrec p = readParen (p > 9) (\r -> [(array b as :: UArray Int Double, u) | ("array",s) <- lex r, (b,t) <- reads s, (as,u) <- reads t ])
The error in linux is: Illegal instance declaration for `Read (UArray Int Double)' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Read (UArray Int Double)'
Why does it want three parameters for the instance type? I am baffled by this.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

It's not just type variables. Type classes looked innocent, but
smuggled an entire turing complete generic meta computation system
into the language. Just thank SIMON that the error messages aren't as
bad as C++ and templates.
This does imply that mOleg have some equivalence relation to uAlexanrescue
On 3/14/07, Bulat Ziganshin
Hello SevenThunders,
Wednesday, March 14, 2007, 10:32:23 PM, you wrote:
the type variables are dark side of GHC, and you need to have at least 1 mlOleg of brain to understand them. it will be great if someone will ever write reasonable introduction into this. meanwhile, you can look into ghc docs
You guys are awesome! I post this not 12 hours ago and I already have a complete treatise on the subject. Yeah to clarify things putting an ellipsis between b and c would help. But also clarify the meaning of distinct type variables. Does this mean the type variable must not be parameterized?
I ran into this because I decided during my port that I would try to learn some of the better build tools on linux. So now I'm acquainted with Cmake, which is a great tool and cabal which is also very impressive. My problem boiled down to the fact that I didn't know how to set the correct compiler flags within cabal. I figured out the FFI flags and now I suppose the gch extensions can be set with Ghc-options: -fglasgow-exts in my .cabal file. Is there a type in the Extensions field that corresponds to this?
Spencer Janssen-2 wrote:
It looks like you forgot to pass a compiler flag, namely -fglasgow-exts.
Cheers, Spencer Janssen
On Tue, 13 Mar 2007 22:20:20 -0700 (PDT) SevenThunders
wrote: I have the pleasure of porting a good sized Haskell application to linux. So far the Haskell code has compiled without incident, however some code that I hacked to implement a Read instance for Unboxed Arrays does not compile on linux even though it compiles just fine on Windows XP in Haskell 6.6.
The code reads as,
instance Read (UArray Int Double) where readsPrec p = readParen (p > 9) (\r -> [(array b as :: UArray Int Double, u) | ("array",s) <- lex r, (b,t) <- reads s, (as,u) <- reads t ])
The error in linux is: Illegal instance declaration for `Read (UArray Int Double)' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Read (UArray Int Double)'
Why does it want three parameters for the instance type? I am baffled by this.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

| The error in linux is: | Illegal instance declaration for `Read (UArray Int Double)' | (The instance type must be of form (T a b c) | where T is not a synonym, and a,b,c are distinct type variables) | In the instance declaration for `Read (UArray Int Double)' | | Why does it want three parameters for the instance type? I am baffled by | this. It's saying that in Haskell 98 you can have instance Read (UArray a b) (for type variables a, b) but not instance Read (UArray Int Double) (As Spencer says, use -fglasgow-exts to lift the H98 restriction.) However, you mis-read the error message to say "the instance type must have three parameters", which isn't what I meant at all! I was trying to use an example of the general form, but conveyed the wrong idea. I can see why you read it that way. Now you understand, can you give me a better error message? Thanks Simon

Simon Peyton-Jones wrote:
| The error in linux is: | Illegal instance declaration for `Read (UArray Int Double)' | (The instance type must be of form (T a b c) | where T is not a synonym, and a,b,c are distinct type variables) | In the instance declaration for `Read (UArray Int Double)' | | Why does it want three parameters for the instance type? I am baffled by | this.
It's saying that in Haskell 98 you can have instance Read (UArray a b) (for type variables a, b) but not instance Read (UArray Int Double)
(As Spencer says, use -fglasgow-exts to lift the H98 restriction.)
However, you mis-read the error message to say "the instance type must have three parameters", which isn't what I meant at all! I was trying to use an example of the general form, but conveyed the wrong idea.
I can see why you read it that way. Now you understand, can you give me a better error message?
I'm not the original poster, but what about just changing it to "The instance type must be of the form (T a1 ... an) where T is not a synonym, and a1 ... an are distinct type variables)"? /Björn

Hello Bjorn, Wednesday, March 14, 2007, 5:27:35 PM, you wrote:
I'm not the original poster, but what about just changing it to "The instance type must be of the form (T a1 ... an) where T is not a synonym, and a1 ... an are distinct type variables)"?
or even better, "are distinct type *variables*", emphasizing important part of the phrase -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Ah, a fine idea. I'll do that anyway; maybe others will have even better ideas, but that's a good start S | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Björn | Bringert | Sent: 14 March 2007 14:28 | To: Simon Peyton-Jones | Cc: haskell-cafe@haskell.org | Subject: Re: [Haskell-cafe] Read Instance for UArray won't port to linux | | Simon Peyton-Jones wrote: | > | The error in linux is: | > | Illegal instance declaration for `Read (UArray Int Double)' | > | (The instance type must be of form (T a b c) | > | where T is not a synonym, and a,b,c are distinct type variables) | > | In the instance declaration for `Read (UArray Int Double)' | > | | > | Why does it want three parameters for the instance type? I am baffled by | > | this. | > | > It's saying that in Haskell 98 you can have | > instance Read (UArray a b) | > (for type variables a, b) but not | > instance Read (UArray Int Double) | > | > (As Spencer says, use -fglasgow-exts to lift the H98 restriction.) | > | > However, you mis-read the error message to say "the instance type must have three parameters", which | isn't what I meant at all! I was trying to use an example of the general form, but conveyed the wrong | idea. | > | > I can see why you read it that way. Now you understand, can you give me a better error message? | | I'm not the original poster, but what about just changing it to "The | instance type must be of the form (T a1 ... an) where T is not a | synonym, and a1 ... an are distinct type variables)"? | | /Björn | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe

Hallo,
On 3/14/07, Simon Peyton-Jones
Ah, a fine idea. I'll do that anyway; maybe others will have even better ideas, but that's a good start
Ah! So now I knows what it means. I've also been beaten by this error message a couple of days ago. Cheers, -- -alex http://www.ventonegro.org/

On 3/14/07, Simon Peyton-Jones
However, you mis-read the error message to say "the instance type must have three parameters", which isn't what I meant at all! I was trying to use an example of the general form, but conveyed the wrong idea.
Oh! I've been wondering what that message was supposed to mean for years. :-) -- Dan
participants (8)
-
Alex Queiroz
-
Björn Bringert
-
Bulat Ziganshin
-
Dan Piponi
-
SevenThunders
-
Simon Peyton-Jones
-
Spencer Janssen
-
Steve Downey