[Haskell-cafe] Making a strict (non-lazy) GCL Interpreter

Hector Guilarte hectorg87 at gmail.com
Tue Jun 30 14:30:24 EDT 2009


Thanks Ketil, I'll try to give that a try, but as I said beforen, I don't know anything about monads, and since this project is for next monday and I have many other projects for the University for next week too I can't learn them right now... What I need to do is randomly select an element from a List... Any Ideas? Also, I had another question in my original e-mail... Any ideas about that?
------Original Message------
From: Ketil Malde
To: Hector Guilarte
Cc: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] Making a strict (non-lazy) GCL Interpreter
Sent: Jun 30, 2009 05:00

Hector Guilarte <hectorg87 at gmail.com> writes:

>   I need to randomly select ONE of the valid conditions and execute it's
> instruction. I know there is a Random Monad, but it returns an IO
> Int,

No, this is not right.  Values in the Random monad are computations
that rely on randomness, but they can produce values of arbitrary
type.  (The 'a' in 'Random a', no?)

> Is there anyway I can do some Random that doesn't involve IO? or any other
> solution?

Some options are:  

1.  Use the IO monad
2.  Use the Random monad
3.  Pass around a RandomGen explicitly
4.  Generate an infinite stream of random values, and pass that around 

I think option 2 is the nicest, but option 4 may work if the use of
randomness is limited.  No. 3 does the same as 2 (I presume, I never
looked) but with a lot more noise in your code, and no. 1 erases the
separation between real IO, and computations -- which IME includes a
lot of them -- that happen to depend on randomness (but require no
other IO).

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants



More information about the Haskell-Cafe mailing list