我正在研究Writer
单子并具有以下内容:
myFunction :: Int -> Int -> Writer String Int
myFunction e1 e2
| e1 > e2 = do
tell ("E1 greater")
return (e1)
| otherwise = do
tell ("E2 greater")
return (e2)
main = do
-- execWriter :: Writer w a -> w
print $ execWriter . myFunction 1 2
错误:
"Couldn't match type ‘WriterT String Data.Functor.Identity.Identity Int’with ‘a0 -> Writer c0 a1’
Expected type: a0 -> Writer c0 a1
Actual type: Writer String Int"
为什么这个计算错误与.
而不是$
?也许我对函数组合的理解不正确?