我开始学习 Haskell,发现了这个程序:http ://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot/Source 。
当我输入它并使用 ghc --make 4.hs tutbot 进行编译时,我收到以下错误:
4.hs:58:10:
Couldn't match expected type `() -> IO b0' with actual type `IO ()'
In the return type of a call of `putStrLn'
Probable cause: `putStrLn' is applied to too many arguments
In the second argument of `bracket', namely `(putStrLn "done.")'
In the expression:
bracket
(printf "Connecting to %s ... " server >> hFlush stdout)
(putStrLn "done.")
a
这是代码:(我检查了嵌入式选项卡并确保所有选项卡都在同一列中):
--
-- Connect to the server and return the initial bot state
--
connect :: IO bot
connect = notify $ do
t <- getClockTime
h <- connectTo server (PortNumber (fromIntegral port))
hSetBuffering h NoBuffering
return (Bot h t)
where
notify a = bracket
(printf "Connecting to %s ... " server >> hFlush stdout)
(putStrLn "done.")
a
--
我看不到这个问题,而且似乎没有其他人遇到过这个问题。