Im pretty new to Haskell.
I have a datatype:
data Sentence= Prop Int
| No Sentence
| And [Sentence]
| Or [Sentence]
deriving Eq
I already wrote a Show instance for it
However, whether it makes sense or not, I would like to be able to generate a random Sentence.
How can i accomplish this in Haskell?
Random number generation is a typical example of an “impure” operation, since calling a random generator twice will of course yield different results – Haskell’s nature disallows this.
Therefore, you need to use a so called monad
Gen athat represents a random generator, that, when run, yields a value of typea.Fortunately, you can combine these generators in a quite nice syntax …
So, you just need some library that implements such a generator – and here we go.