The following code, which is verbatim from LYAH, doesn't compile. Code and compile-time error are included below. On the LYAH page, the code is ~15% down the page, yay emacs browser :)
Any ideas why? Am I overlooking something totally obvious?
(Despite the similarity in post-titles, I think my question is different from this one.)
Here's the code (in a file which I named testcopy.hs
)
import Control.Monad.Writer
logNumber :: Int -> Writer [String] Int
logNumber x = Writer (x, ["Got number: " ++ show x])
multWithLog :: Writer [String] Int
multWithLog = do
a <- logNumber 3
b <- logNumber 5
return (a*b)
And here's the compile-time error:
Prelude> :l testcopy.hs
[1 of 1] Compiling Main ( testcopy.hs, interpreted )
testcopy.hs:4:15:
Not in scope: data constructor `Writer'
Perhaps you meant `WriterT' (imported from Control.Monad.Writer)
Failed, modules loaded: none.