[英]Matching types and monads. Error
type C = StateT Int (ErrorT String IO)
main :: C ()
main = do
args <- liftIO $ getArgs
case args of
[] -> liftIO $ putStrLn "E"
(p:ps) -> s "d"
s :: String -> C ()
I've got the error: 我有错误:
Couldn't match type ‘Control.Monad.Trans.State.Lazy.StateT
Int
(Control.Monad.Trans.Error.ErrorT String IO)
()’
with ‘IO t0’
Expected type: IO t0
Actual type: C ()
In the expression: main
When checking the type of the IO action ‘main’
I cannot understand why there is an error and how to repair it. 我不明白为什么会有错误以及如何修复。 Please help. 请帮忙。
main
must be of type IO a
for some a
(usually, but not necessarily, ()
). main
对于某些a
(通常,但不一定是()
)必须是IO a
类型。 It can't be of type StateT Int (ErrorT String IO)
. 它不能为StateT Int (ErrorT String IO)
。 You can fix this by using the functions provided with StateT
and ErrorT
for converting them to actions of the underlying monad. 您可以使用StateT
和ErrorT
的函数将其转换为基础monad的动作来解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.