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@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to