I see..

(Presumably you meant "instance Alg Sometype",
"instance Vec Sometype" etc.)

I have got it working now, and it looks like:
1) I can't specialise superclass methods with other
class methods, within the class hierarchy, and
2) I have to instantiate each superclass individually,
for any type.

...which is consistent with what you were saying.
Thanks for clearing that up.

Now I know what they meant what they meant by "leave
your OO at the door".


--- [EMAIL PROTECTED] wrote:

...

> What you'll have to do until then is something like
> this:
> 
>      class Num a => Alg a where
>          (<>)    :: Mat m => m -> a -> a
> 
>      multByVec :: (Vec v, Mat m) => m -> a -> a
>      multByVec m v = fromColumn (m <> toColumn v)
> 
>      class Alg v      => Vec v where
>          toRow, toColumn     :: Mat m => v -> m
>          fromRow, fromColumn :: Mat m => m -> v
> 
>          fromRow     = fromColumn . transpose
>          toRow       = transpose . toColumn
> 
>      class Alg m     => Mat m where
>          transpose   :: m -> m
> 
>      class Alg SomeType where
>          (<>) = multByVec
> 
>      class Vec SomeType where
>          toRow = {- etc etc -}
>          {- and so on -}
> 
> Sorry, I wish there was a better answer.
> 
> Cheers,
> Andrew Bromage
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 



      Make the switch to the world's best email. Get the new Yahoo!7 Mail now. 
www.yahoo7.com.au/worldsbestemail


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to