我想知道如何在GHCI中映射{place0: 1,place1: 2,place2: 3,place3: 4}
。
IO [Int]
所需结果:
λ: :{
λ| th :: IO [Int]
λ| th = pure [1,2,3,4]
λ| :}
λ: th
[1,4]
λ: :t th
th :: IO [Int]
λ: map (+2) th
• Couldn't match expected type ‘[b]’ with actual type ‘IO [Int]’
• In the second argument of ‘map’,namely ‘th’
In the expression: map (+ 2) th
解决方案可能非常明显,但不知何故我无法解决问题。