import Control.Monad.Error import Control.Monad.Writer type Debug m a = ErrorT a (WriterT String m) a test :: Debug IO String test = do liftIO $ print "hej" liftIO $ print "hej" debug "DEBUG!!!" liftIO $ print "hej" liftIO $ print "hu" return "hh" debug s = lift $ tell s assert True = return () assert False = return () run f = runErrorT $ runWriterT f