Question: I am using Haskell and have declared a `Vector` as

```
data Vector = Vector [Double]

```

Now, I want to declare the `dot` product of two vectors as

```
dot :: Vector -> Vector -> Double
dot a b = sum $ a * b -- I already wrote Vector as an instance of Num for *.

```

But, the problem is, I receive the error

```
Couldn't match expected type [a0] with actual type Vector

```

I assume this means that `sum` doesn't know how to operate on a `Vector`. What is the best way to approach this issue?

Answer: 
You are using sum from Prelude with type:

`sum :: Num a => [a] -> a`

sum for vectors is defined in Data.Vector (usually imported qualified)

edit: I missed the fact that you are using your own datatype, not the one from Data.Vector
To a create a dot function you could do

```
data Vector = Vector [Double]

dot :: Vector -> Vector -> Double
dot (Vector a) (Vector b) = sum $ zipWith (*) a b

```

This way 'a' and 'b' are now the [Double] inside of the Vector and not the Vector its self.

Step-by-step:

```
dot (Vector [1,2]) (Vector [3,4]) = sum $ zipWith (*) [1,2] [3,4]

= sum $ zipWith (*) [1,2] [3,4]
= sum $ [1*3, 2*4]
= 1*3 + 2*4
= 3 + 8
= 11

```