[Haskell-beginners] Randomly selecting a data constructor

Evgenij Merenkov evgenij1 at hotmail.com
Sun Mar 14 08:53:41 EDT 2010


Thank you. Didn't know that you can supply type directly to a function, like "f :: Type".

> From: gale at sefer.org
> Date: Sun, 14 Mar 2010 13:44:39 +0200
> Subject: Re: [Haskell-beginners] Randomly selecting a data constructor
> To: tom.davie at gmail.com
> CC: beginners at haskell.org; evgenij1 at hotmail.com
> 
> Sorry, hit "Send" too soon:
> 
> >> data FigType = TR1 | TR2 | TR3 | TR4 | SQ | L1 | L2 | Z1 | Z2 | Z3 | Z4 |
> >> NoFigure
> >>                deriving (Enum, Bounded)
> >> randomFigure :: IO FigType
> >> randomFigure = toEnum <$> randomRIO
> >>   (fromEnum (minBound :: FigType),
> >>    fromEnum (maxBound :: FigType))
> 
> -Yitz
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
 		 	   		  
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100314/2f197f4a/attachment.html


More information about the Beginners mailing list