Skip to content

Instantly share code, notes, and snippets.

@lspitzner
Created December 24, 2014 23:39
Show Gist options
  • Save lspitzner/9fcc232aba9c18c8ca7d to your computer and use it in GitHub Desktop.
Save lspitzner/9fcc232aba9c18c8ca7d to your computer and use it in GitHub Desktop.
small example for Writer vs WriterT error message
module Main where
import Control.Monad.Trans.Writer
import Data.Monoid ( Sum(..) )
f :: Writer (Sum Int) ()
f = undefined
g :: Writer (Sum Int) Int
g = do
tell $ Sum 1
f
main = return ()
{-
Main.hs:10:3:
Couldn't match type ‘()’ with ‘Int’
Expected type: WriterT (Sum Int) Data.Functor.Identity.Identity Int
Actual type: Writer (Sum Int) ()
In a stmt of a 'do' block: f
In the expression:
do { tell $ Sum 1;
f }
Failed, modules loaded: none.
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment