Proposal: Generalize the RandomGen and Random classes

Simon Peyton-Jones simonpj at microsoft.com
Wed Sep 15 03:58:55 EDT 2010


| class RandomGen g v | g -> v where
|     next :: g -> (v, g)
|     genRange :: g-> (v,v)

Or, perhaps nicer,

class RandomGen g where
  type RandomVal g
  next :: g -> (RandomVal g, g)
  genRange :: g -> (RandomVal g, RandomVal g)

where "RandomVal g" means "the type of values
produced by generator g".

Simon


More information about the Libraries mailing list