私は次のような単純な関数を持っています:
nth :: Integer -> Integer
そして、私はその結果を次のように印刷しようとします:
main = do
n <- getLine
result <- nth (read n :: Integer)
print result
次のエラーが生成されます。
Couldn't match expected type `IO t0' with actual type `Integer'
In the return type of a call of `nth'
In a stmt of a 'do' expression:
result <- nth (read n :: Integer)
またputStrLn
、運が悪かった他の多くの組み合わせで試してみました。
私はそれを理解することができず、何かがこれらの周りでどのように機能するかを完全に理解していないので、私はいくつかの助けが必要ですIO
。