Hello, Cafe I'm new to Haskell and the mailing list, and am wondering if I could get some feedback on my first program -- a Markov text generator. The code is posted here:http://codereview.stackexchange.com/questions/24791/haskell-markov-text-gene... Thanks, John;
Hi John, I am not saying it's wrong, but something you could consider trying is using the RVars to generate the random numbers inside MonadRandom and using lift to lift the random number generation into the state Monad and use runStateT. The IO Monad is an instance of MonadRandom so any State + MonadRandom computation can be run inside the IO Monad. I will write a short piece of code to illustrate my point. import Data.Random.Distribution.Uniform import Control.Monad.State import Data.RVar ... randomState n = do let dist = uniform 1 n rNum <- lift $ sampleRVar dist put rNum runStateT (randomState 5) 0 Using RVars, you can generate numbers from numerous distributions. You can even have pure RVars which generate values according to a distribution once an initialization seed is given. I hope this information serves you well. Check out the RVar package in Haskell for more about generating random numbers. Best, Ernesto Rodriguez On Sat, Apr 6, 2013 at 6:50 PM, John Wood <j@jdtw.us> wrote:
Hello, Cafe
I'm new to Haskell and the mailing list, and am wondering if I could get some feedback on my first program -- a Markov text generator. The code is posted here:
http://codereview.stackexchange.com/questions/24791/haskell-markov-text-gene...
Thanks,
John;
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Ernesto Rodriguez Bachelor of Computer Science - Class of 2013 Jacobs University Bremen
participants (2)
-
Ernesto Rodriguez -
John Wood