[Haskell-cafe] Fundeps: I feel dumb
Creighton Hogg
wchogg at gmail.com
Wed Apr 12 22:12:11 EDT 2006
Hi,
So I'm trying the fun-deps example from
http://www.haskell.org/hawiki/FunDeps and seeing if I can
use it, but I can't really get things to work the way I want.
The code follows below, and the error I get if I try to multiply
10 <*> (vector 10 [0..9]) is
No instance for (MatrixProduct a (Vec b) c)
arising from use of `<*>' at <interactive>:1:3-5
Probable fix: add an instance declaration for (MatrixProduct a (Vec b) c)
In the definition of `it': it = 10 <*> (vector 10 ([0 .. 9]))
import Array
-- The elements and the size
data Vec a = Vec (Array Int a) Int
deriving (Show,Eq)
type Matrix a = (Vec (Vec a))
class MatrixProduct a b c | a b -> c where
(<*>) :: a -> b -> c
instance (Num a) => MatrixProduct a (Vec a) (Vec a) where
(<*>) num (Vec a s) = Vec (fmap (*num) a) s
vector n elms = Vec (array (0,n-1) $ zip [0..n-1] elms) n
More information about the Haskell-Cafe
mailing list