请帮助我理解以下定义:
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')
为什么 runWriter 被声明为
runWriter :: (a,w)
当它的实际类型是:
runWriter :: Writer w a -> (a, w)
一旦我尝试使用 ghci,我意识到这一定是一些隐含的论点,因为必须确定类型“a”,但这里到底发生了什么?