Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-09 Thread DavidA
Malcolm Wallace malcolm.wallace at me.com writes: data Bar f a = Foo f = Bar {bar :: f a} The class context on the data constructor buys you nothing extra in terms of expressivity in the language. All it does is force you to repeat the context on every function that uses the

Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-09 Thread Erik Hesselink
On Thu, Jun 9, 2011 at 09:46, DavidA polyom...@f2s.com wrote: I think that's exactly what the original poster is complaining about. As a real- life example, consider data Graph a = Ord a = G [a] [[a]] My intention is that whenever I have a Graph a, I want to be able to use the Ord

Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-09 Thread Guy
...@gmx.de To: haskell-cafe@haskell.org Cc: Guy guytsalmave...@yahoo.com Sent: Thursday, 9 June 2011, 2:06 Subject: Re: [Haskell-cafe] Type Constraints on Data Constructors Hello, you might be thinking of this type? {-# LANGUAGE Rank2Types #-} class Foo f where     foo :: a - f a data Baz

Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-09 Thread Daniel Schüssler
Correction: I meant data Baz f a = Baz (Foo f = f a) (Dropped the 'forall', which would make the inner 'f' have nothing to do with the type parameter 'f' of 'Baz') On 2011-June-09 Thursday 01:07:13 Daniel Schüssler wrote: Hello, you might be thinking of this type? {-# LANGUAGE

Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-09 Thread Daniel Schüssler
- From: Daniel Schüssler dan...@gmx.de To: haskell-cafe@haskell.org Cc: Guy guytsalmave...@yahoo.com Sent: Thursday, 9 June 2011, 2:06 Subject: Re: [Haskell-cafe] Type Constraints on Data Constructors Hello, you might be thinking of this type? {-# LANGUAGE Rank2Types #-} class

Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-09 Thread Guy
Malcolm Wallace malcolm.wallace at me.com writes: The class context on the data constructor buys you nothing extra in terms of expressivity in the language. All it does is force you to repeat the context on every function that uses the datatype. For this reason, the language committee has

[Haskell-cafe] Type Constraints on Data Constructors

2011-06-08 Thread Guy
{- continuing discussion from beginners@ -} I have code such as class Foo f where foo :: a - f a data Bar f a = Foo f = Bar {bar :: f a} instance Foo (Bar f) where foo a = Bar $ foo a GHC insists that I put Foo f = on the instance declaration, even though the constructor for Bar

Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-08 Thread Malcolm Wallace
data Bar f a = Foo f = Bar {bar :: f a} The class context on the data constructor buys you nothing extra in terms of expressivity in the language. All it does is force you to repeat the context on every function that uses the datatype. For this reason, the language committee has decided

Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-08 Thread David Menendez
On Wed, Jun 8, 2011 at 3:15 PM, Malcolm Wallace malcolm.wall...@me.com wrote: data Bar f a = Foo f = Bar {bar :: f a} The class context on the data constructor buys you nothing extra in terms of expressivity in the language.  All it does is force you to repeat the context on every function

Re: [Haskell-cafe] Type Constraints on Data Constructors

2011-06-08 Thread Daniel Schüssler
Hello, you might be thinking of this type? {-# LANGUAGE Rank2Types #-} class Foo f where foo :: a - f a data Baz f a = Baz (forall f. Foo f = f a) instance Foo (Baz f) where foo a = Baz (foo a) Maybe the difference between Bar and Baz ist best explained by writing it with an