Haskell: No instance for (Monoid Int) when using writer monad with haskell 2013 2.0.0 framework
module Main where
import Data.Char
import Control.Monad
import Control.Monad.Trans.Writer
import Control.Applicative
import Data.Monoid
wt :: Int -> Writer Int [String]
wt x=writer(["num:"++ show x],x)
addw::Writer Int [String]
addw = do
a <- wt 2
b <- wt 3
return (a*b)
There are 2 errors:
No instance for (Monoid Int) arising from a do statement
Possible fix: add an instance declaration for (Monoid Int)
In a stmt of a 'do' block: a <- wt 2
In the expression:
do { a <- wt 2;
b <- wt 3;
return (a * b) }
In an equation for `addw':
addw
= do { a <- wt 2;
b <- wt 3;
return (a * b) }
No instance for (Num [String]) arising from a use of `*'
Possible fix: add an instance declaration for (Num [String])
In the first argument of `return', namely `(a * b)'
In a stmt of a 'do' block: return (a * b)
In the expression:
do { a <- wt 2;
b <- wt 3;
return (a * b) }
I am using eclipse 4.4 juno with newest eclipsefp, haskell 2013 2.0.0 platform includes ghc 7.6.3, this code snippet is to find out you haskell for great quality
+3
source to share