G'day all.

Quoting alex <[EMAIL PROTECTED]>:

I would like to do this:

    class Foo t where
        hi :: t -> Bool

    class Foo t => Bar t where
        hi x = True

This is arguably one of the most requested features in Haskell.  The only
reason why it hasn't been implemented yet is that some of the corner cases
are a little subtle.

But this will get fixed, won't it, haskell-prime people?

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

Reply via email to