我整天都在尝试编译 Haskell 代码 - 再次 - 涉及 Control.Monad.Writer。这是一个不会从Learn You a Haskell编译的代码示例:
import Control.Monad.Writer  
gcd' :: Int -> Int -> Writer [String] Int  
gcd' a b  
    | b == 0 = do  
        tell ["Finished with " ++ show a]  
        return a  
    | otherwise = do  
        tell [show a ++ " mod " ++ show b ++ " = " ++ show (a `mod` b)]  
        gcd' b (a `mod` b)
我收到此错误:
No instance for (Show (Writer [String] Int))
      arising from a use of `print'
    Possible fix:
      add an instance declaration for (Show (Writer [String] Int))
    In a stmt of an interactive GHCi command: print it
我已经尝试编译我的老师今天编写的代码,也涉及 Control.Monad.Writer,但没有任何效果。
我正在使用 Ubuntu 12.04、gedit 和 GHC 7.4.1。
Learn You a Haskell中的所有 Writer monad 程序都无法编译,我被困住了。