I'd like to know how to map over an IO [Int] in GHCI.
λ: :{
λ| th :: IO [Int]
λ| th = pure [1, 2, 3, 4]
λ| :}
λ: th
[1,2,3,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
Desired result:
λ: res = map (+2) th -- <-- some working version of this
λ: res
[3, 4, 5, 6]
λ: :t res
res :: IO [Int]
The solution is probably very obvious but somehow I can't wrap my head around it.