Re: [Haskell-cafe] Polymorphic algebraic type constructors

data E a b = L1 { r :: a } | L2 { r :: a } | L3 { r :: a } | L4 { r :: a } | R b deriving Show
How is this different from: data E a b = L1 a | L2 a | R b f g (R a) = R (g a) f _ other = other Isn't this more or less what was in the original... The problem is the type: f :: (a->b) -> Either String a -> Either String b this line: f _ other = other says: Either String a == Either String b -- which it doesn't Keean.

On Tue, Jun 22, 2004 at 01:29:02PM +0100, MR K P SCHUPKE wrote:
data E a b = L1 { r :: a } | L2 { r :: a } | L3 { r :: a } | L4 { r :: a } | R b deriving Show
How is this different from:
data E a b = L1 a | L2 a | R b
f g (R a) = R (g a) f _ other = other
Isn't this more or less what was in the original...
Nope. My f has type (b -> b1) -> E a b -> E a b1
The problem is the type:
f :: (a->b) -> Either String a -> Either String b
this line: f _ other = other
says: Either String a == Either String b -- which it doesn't
Record update avoids this because of the way it is translated. Basically, the result of record update is a reconstructed record, but constructors not containing updated fields are not built/copied, so they don't constrain the resulting type. See Haskell 98 Report for details. Anyway, I doubt the OP can benefit from it.
Keean.
Best regards, Tom -- .signature: Too many levels of symbolic links

On Tue, Jun 22, 2004 at 02:52:21PM +0200, Tomasz Zielonka wrote:
Record update avoids this because of the way it is translated. Basically, the result of record update is a reconstructed record, but constructors not containing updated fields are not built/copied, so they don't constrain the resulting type. See Haskell 98 Report for details.
Sorry, I confused some facts. It suffices that result of labeled record update is a newly constructed record (or bottom). Best regards, Tom -- .signature: Too many levels of symbolic links
participants (2)
-
MR K P SCHUPKE
-
Tomasz Zielonka