Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mitchellh
Created September 26, 2009 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchellh/194018 to your computer and use it in GitHub Desktop.
Save mitchellh/194018 to your computer and use it in GitHub Desktop.
-- ch14/Logger.hs
type Log = [String]
newtype Logger a = Logger { execLogger :: (a, Log) }
instance Monad Logger where
return a = Logger (a, [])
m >>= k = let (a, s) = execLogger m
mb = k a
(b, s') = execLogger mb
in Logger (b, s ++ s')
record s = Logger ((), [s])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment