Map over IO [Int] in GHCI

You can make use of fmap :: Functor f => (a -> b) -> f a -> f b to performing a mapping over the values of a Functor. Since IO is a functor, you can thus use this to post-process the result of an IO action:

Prelude> fmap (map (+2)) th

You can also use the infix operator (<$>) :: Functor f => (a -> b) -> f a -> f b which is an alias:

Prelude> map (+2) <$> th

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top