papa.e...@free.fr escribió: > Hi haskell helpers, > > Learning haskell, I wanted to explore how to write pure code and then > add some IO on top of it, keeping the main code pure. The idea was to > write a very simple two-player game, then define some strategies to > play it that do not involve IO, and finally use strategies involving > Random or IO ("ask the user"). I failed to reuse the pure code, and > the only solution I found was to rewrite most things for IO. Here is > my attempt in literate haskell, it is quite short, I hope someone will > be kind enough to tell me what I have missed... Thanks for any answer! I know mainly two options, the first is using unsafe IO which is a small heresy.
The other is using the Control.Monad lift function which will apply pure functions over IO ones returning an IOized type. Ie if we have an b :: IO Int b = return 3 and we do c = lift (+ 2) b We will get IO(5) when we use c
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe