Monad and MonadIO for custom type
问题 I have a Logger type of kind * -> * which can take any type and log the value in a file. I am trying to implement this in a monadic way so that I log and keep working the same. My code looks like import Control.Applicative import Control.Monad import System.IO import Control.Monad.IO.Class instance Functor Logger where fmap = liftM instance Applicative Logger where pure = return (<*>) = ap newtype Logger a = Logger a deriving (Show) instance Monad (Logger) where return = Logger Logger logStr