Field labels must be globally unique?

Marc Ziegert coeus@gmx.de
Wed, 8 Jan 2003 14:35:08 +0100


--Just changed the syntax:


...
--------------------or BETTER just to split classes:

type class HalfBody a = (Num a => (+), (-))

instance HalfBody Vector where
    (+) v1 v2 = ...
    (-) v1 v2 = ...

...



----- Original Message -----
From: "Marc Ziegert" <coeus@gmx.de>
To: <haskell@haskell.org>
Sent: Wednesday, January 08, 2003 2:24 PM
Subject: Re: Field labels must be globally unique?


> --------------------It would be nice to be able to overload class-functions like classes:
>
> instance (+), (-) -> Vector where
>     (+) v1 v2 = ...
>     (-) v1 v2 = ...
>
> --------------------instead of overloading parts of a class... (because of runtime-errors!)
>
> instance Num Vector where
>     (+) v1 v2 = ...
>     (-) v1 v2 = ...
>     (*) _ _ = undefined
>     (/) _ _ = undefined
>
> --------------------or BETTER just to split classes:
>
> class HalfBody a => (Num a =>(+), (-)) where
>
> instance HalfBody Vector where
>     (+) v1 v2 = ...
>     (-) v1 v2 = ...
>
> --------------------instead of defining new operators...
>
> class HalfBody a where
>     (+§) :: a -> a -> a
>     (-§) :: a -> a -> a
>
> instance (Num a) => HalfBody a where
>     (+§) = (+)
>     (-§) = (-)
>
> instance HalfBody Vector where
>     (+§) v1 v2 = ...
>     (-§) v1 v2 = ...
>
> --------------------------------------------------------------------------------
> > > One is to allow function overloading.  This is probably not desirable
> > > because it turns type checking into an NP-hard problem.
>
>
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>
>