【发布时间】:2019-06-22 09:15:47
【问题描述】:
在循环中,整数被收集在一个列表中,这些整数的元组是returned。这如何更改为元组列表?
input :: IO [(Int,Int)]
input = do
n <- readLn :: IO Int
forM [1..n] $ \_ -> do
[x,y] <- map read . words <$> getLine
return (x,y)
我预计值的类型是(Int,Int),但它是[(Int,Int)]。为什么?
【问题讨论】:
-
您的问题到底是什么?我真的不清楚你在问什么
-
没有“退货声明”。
return是一个函数(和一个虚拟构造函数)。
标签: haskell types type-inference io-monad do-notation