sleepomeno.github.io - while true live

Description: Every wanted to roll the dice in Haskell? Let’s say you have a data type like 1 2 data Number = One | Two | Three | Four | Five | Six deriving …

Example domain paragraphs

Every wanted to roll the dice in Haskell? Let’s say you have a data type like

1 2 data Number = One | Two | Three | Four | Five | Six deriving ( Enum , Bounded , Eq , Show ) How do you generate a random Number value? There are several ways to do it, usually in an IO context, obviously. In order to use it in a common monad transformer stack, the primitives of the MonadRandom type class come to my mind. So it would be most convenient to get a random value using getRandom . Anyway, as much fun as rolling the dice is, let’s derive a solution working for all bounded Enums.

Sep 13 th , 2015