#g --
At 13:38 22/06/04 +0100, Adrian Hey wrote:
I think this was the topic of my very first post to Haskell mailing list, many years ago..
http://www.dcs.gla.ac.uk/mail-www/haskell/msg00452.html
I think the answer is no. Apparently this is feature (I still think it's a bug though:-)
Regards -- Adrian Hey
On Monday 21 Jun 2004 6:03 pm, Graham Klyne wrote: > If I have a polymorphic algebraic type (T a) with several type > constructors, only one of which actually references the type parameter, is > there any way to express type conversion for the type-parameter-independent > constructors without actually mentioning all the constructors? > > Here's a simple example based on Either: > > [[ > data A = A String deriving (Show, Eq) > data B = B String deriving (Show, Eq) > > f :: (a->b) -> Either String a -> Either String b > f g (Right a) = (Right $ g a) > f g (Left s) = (Left s) > -- f g (s) = (s) -- doesn't work > > a2b (A s) = (B s) > > t1 = f a2b (Left "x") > t2 = f a2b (Right (A "y")) > ]] > > The second case for 'f' throws a type error when the constructor 'Left' is > omitted, because the type of 's' is fixed to be Either String A when the > required result (in this case, because of a2b) is Either String B. > > #g > > > ------------ > Graham Klyne > For email: > http://www.ninebynine.org/#Contact > > _______________________________________________ > Haskell-Cafe mailing list > [EMAIL PROTECTED] > http://www.haskell.org/mailman/listinfo/haskell-cafe
------------ Graham Klyne For email: http://www.ninebynine.org/#Contact
_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe