【发布时间】:2014-11-20 04:09:46
【问题描述】:
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)
有2个错误:
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) }
我使用带有最新 eclipsefp 的 eclipse 4.4 juno,haskell 平台 2013 2.0.0 包括 ghc 7.6.3,这段代码 sn-p 来自于学习你的 haskell for great good
【问题讨论】:
标签: haskell types functional-programming ghc