2016-10-29 11 views
2
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() 

私はエラーを持っている:マッチングタイプとモナド。エラー

 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’ 

エラーとどのようにそれを修復することがありますなぜ私は理解できません。助けてください。

+0

[Haskellの主な特長は何ですか?](0120-17753-1) – duplode

答えて

5

mainは、a(通常は、必ずではありませんが、())はIO aである必要があります。タイプはStateT Int (ErrorT String IO)であることはできません。これを修正するには、StateTErrorTで提供されている関数を使用して、それらを基になるモナドのアクションに変換します。

+0

"これを修正するには、関数StateTとErrorTを提供して、それらを元のモナドのアクションに変換します。 "どういう意味ですか? – Gilgamesz

+0

@Gilgameszなど、 'runStateT'と' runErrorT'です。 –

+0

ありがとう:) – Gilgamesz

関連する問題