Please help me to understand the following definition:
newtype Writer w a = Writer { runWriter :: (a,w) }
instance (Monoid w) => Monad (Writer w) where
return a = Writer (a,mempty)
(Writer (a,w)) >>= f = let (a',w') = runWriter $ f a in Writer (a',w `mappend` w')
Why is runWriter is declared as
runWriter :: (a,w)
when its actual type is:
runWriter :: Writer w a -> (a, w)
Once I tried with ghci I realized this must be some implicit argument since type "a" has to be determined, but what is exactly happening here?