[Haskell-cafe] Help mixing pure and IO code

klondike klondikehaskellcafe at xiscosoft.es
Mon Nov 30 18:34:12 EST 2009


Eric Dedieu escribió:
> Still more importantly to me, I understand that anyhow  if I intend to
> use IO or random numbers, I must design my strategy from the beginning
> as "encapsulated in a monad". Something like:
>
> class (Monad m) => Strategy m a where ...
>   
That's not true at all, you can always pass this data to your strategy
entry points and let haskell get it lazily, though it is not as
intuitive as other aproaches,

Ie. I need to get the next pick for my IA so I can use a function called
get IA wich would take as arguments a random seed (or an infinite vector
of random numbers using laziness ;) ) and the previous user inputs and
strategy outputs.

Of course this is just retarding the monadification of the function as
soon or later you'll have to embed it into a IO monad to get the desired
results. Anyway, making the strategies completely deterministic can also
be useful when debugging.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091130/b2f1abbe/signature.bin


More information about the Haskell-Cafe mailing list