2 ms·
> You cannot easily convert between functional and monadic style without a radical restructuring of code. Yes you can, though you do it backwards from what man
by codygman 11y ago
> You cannot easily convert between functional and monadic style without a radical restructuring of code.
Yes you can, though you do it backwards from what many people expect. Instead of getting something out of IO why not put the pure function into IO?
This can be done with liftM and fmap.
> let x = return 1 :: IO Int
> let z = fmap (+ 1) x
> z
2
> :type z
z :: IO Int