So I have two data types. For simplicity say one holds an Int and one holds a String.
So let’s say I have
data ranData = randInt Int | randString String
How can I make a function that will either choose one of these and then give it a random value. I have some ideas, but they are rather inelegant.
Assuming that you want to use the
MonadRandompackage:The
randomDatafunction will generate aRanDatain theRandmonad, with some random number generatorg. TheevalRandIOfunction will extract the randomRanDatausing theStdGenrandom number generator. There are many other random number generators and ways to run them; this was only an example.