Why i get this error in my code: code:
module Task5 where
import Prelude
data Stream a = a :& Stream a
infixl 4 :&
add :: Num a => a -> a -> a
add a b = a + b
instance Num (Stream a ) where
(+) (ia:&a) (ib :& b) = (ia + ib) :& ((+) a b)
error:
Task5.hs:14:33:
No instance for (Num a) arising from a use of `+'
Possible fix:
add (Num a) to the context of the instance declaration
In the first argument of `(:&)', namely `(ia + ib)'
In the expression: (ia + ib) :& ((+) a b)
In an equation for `+':
+ (ia :& a) (ib :& b) = (ia + ib) :& ((+) a b)
I don't understand how to correct this , i tried it for all week , but not find any solution. So , can you say me what i should correct?