Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Kurt Stutsman
Antoine Latter wrote: 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 When I enable that flag, I then also have to enable

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Chris Smith
On Wed, 2011-02-23 at 08:42 -0600, Kurt Stutsman wrote: When I was reviewing the Haskell language specification on haskell.org, it certainly looked like what I was doing was supported by the language. I found some comments on GHC's site about the reasoning behind these flags, but I couldn't

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Daniel Fischer
On Wednesday 23 February 2011 15:42:46, Kurt Stutsman wrote: Antoine Latter wrote: 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 #-}

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Kurt Stutsman
Daniel Fischer wrote: No, it's not. The language report says an instance head must have the form (tyCon a1 ... an), where tyCon is a type constructor and a1 ... an are *distinct* type variables (appropriate in number so that the head has the correct kind). In instance (Enum e) = Test e

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Stephen Tetley
On 23 February 2011 15:40, Kurt Stutsman kstuts...@gmail.com wrote: instance Enum e = Serializable e where   get mask = {- convert mask to Int and then to a BitSet -}   put bitset = {- convert BitSet to Int and then to String -} I looks like all you need is for objects to be enumerable, i.e

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Steffen Schuldenzucker
Hi, On 02/23/2011 04:40 PM, Kurt Stutsman wrote: [...] Test is actually a kind of Serializable class. I don't want to restrict it to only working with Enums, which is what your OverlappingInstances seems to address. Is there a better way for doing what I am trying to do? Example: import

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Kurt Stutsman
Stephen Tetley wrote: On 23 February 2011 15:40, Kurt Stutsman kstuts...@gmail.com wrote: instance Enum e = Serializable e where get mask = {- convert mask to Int and then to a BitSet -} put bitset = {- convert BitSet to Int and then to String -} I looks like all you need is for

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Brandon Moore
From Kurt Stutsman kstuts...@gmail.com on Wed, February 23, 2011 9:40:09 AM Daniel Fischer wrote: No, it's not. The language report says an instance head must have the form (tyCon a1 ... an), where tyCon is a type constructor and a1 ... an are *distinct* type variables

Re: [Haskell-cafe] Having trouble with instance context

2011-02-22 Thread Ivan Lazar Miljenovic
On 23 February 2011 13:10, Kurt Stutsman kstuts...@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

Re: [Haskell-cafe] Having trouble with instance context

2011-02-22 Thread Kurt Stutsman
Ivan Lazar Miljenovic wrote: On 23 February 2011 13:10, Kurt Stutsman kstuts...@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

Re: [Haskell-cafe] Having trouble with instance context

2011-02-22 Thread Antoine Latter
On Tue, Feb 22, 2011 at 8:37 PM, Kurt Stutsman kstuts...@gmail.com wrote: Ivan Lazar Miljenovic wrote: On 23 February 2011 13:10, Kurt Stutsman kstuts...@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