yonutix
yonutix

Reputation: 2449

Haskell data type parametrized with random generator data type

How can I parametrize a data type with a random generator data type? I tried this:

data DataType g = Data (RandomGen g)

But I get

Predicate `RandomGen g' used as a type
In the type `RandomGen g'
In the definition of data constructor `Data'
In the data declaration for `DataType'
Failed, modules loaded: GameState.

Upvotes: 0

Views: 94

Answers (1)

arrowd
arrowd

Reputation: 34411

RandomGen is a type class, not type. Use StdGen if that fits you. And it isn't parametrized by anything, so you need just data DataType = Data StdGen.

Upvotes: 3

Related Questions