[Haskell-cafe] better way to do this?

Michael Mossey mpm at alumni.caltech.edu
Mon Oct 5 10:24:00 EDT 2009


If I understand correctly, this works because IO is an instance of 
Applicative, correct?

I wonder if any of the random monads are instances of Applicative.

Felipe Lessa wrote:
> On Sun, Oct 04, 2009 at 01:55:11PM +0400, Eugene Kirpichov wrote:
>> [x,y,t,b,l,r] <- mapM (getStdRandom . randomR) [(-10,10), (-70,70), ...]
>> return (BoxBounds ...)
> 
> import Control.Applicative
> 
> let f = getStdRandom . randomR
>     g1 = \x -> f (-x,x)
>     g2 = f (5,10)
> in BoxBounds <$> g1 10 <*> g1 70 <*> g2 <*> g2 <*> g2 <*> g2
> 
> --
> Felipe.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list