mercredi 21 février 2018

Haskell random IO to Int

I recently picked up Haskell and the syntax is really confusing to me. I am trying to get a random number between 0 and 51 using

randomRIO (0, 51)

But I dont know how to make this an actual Int (now its type IO a). I believe you are supposed to be able to do:

gen <- randomRIO (0, 51)

and then gen is supposed to be an Int but I have to do this in a do block? How do I create the function that takes this and return an Int. From googeling I'm afraid that there is something basic that I do not understand. I am completely lost.




Aucun commentaire:

Enregistrer un commentaire