[Haskell-cafe] monte carlo trouble

Chad Scherrer chad.scherrer at gmail.com
Wed Aug 15 15:57:07 EDT 2007


Funny you should say that, I was just experimenting with generating
one at a time using (StateT StdGen Maybe). If I get stuck (again) I'll
check out ListT. Thanks!

Chad

On 8/15/07, Paul Johnson <paul at cogito.org.uk> wrote:
> Chad Scherrer wrote:
> > Thanks for your replies.
> >
> > I actually starting out returning a single element instead. But a
> > given lookup might return [], and the only way I could think of to
> > handle it in (State StdGen a) would be to fail in the monad. But
> > that's not really the effect I want - I'd rather have it ignore that
> > element. Another option was to wrap with Maybe, but then since I
> > really want  a sequence of them anyway, I decided to just wrap in a
> > List instead. Is there a way Maybe would work out better?
> Ahh.  How about using ListT Gen then?  That (if I've got it the right
> way round) works like the list monad (giving you non-determinism), but
> has your random number generator embedded as well.  Take a look at "All
> About Monads" at http://www.haskell.org/all_about_monads/html/.  Each
> action in the monad may use a random number and produce zero or more
> results.
>
> Paul.


-- 

Chad Scherrer

"Time flies like an arrow; fruit flies like a banana" -- Groucho Marx


More information about the Haskell-Cafe mailing list