0
propertyForStringsFromMyCharPool :: String -> Bool
-- implementation

main = T.quickCheck propertyForStringsFromMyCharPool

Right now QuickCheck generates all kinds of strings, but I want to test my property only for strings from my pool of characters.

My output now is:

*** Failed! Falsifiable (after 3 tests and 2 shrinks):    
"-"

But it is not a real failure because - is not included in my charset and no string containing it should have been generated in the first place.


  • I have tried to read the read the docs of QuickCheck but they are very abstract and hard, I did not find a sloution.

  • I have seen a solution on StackOverflow but it seems so much code for what looks like an easy problem, that I fear it is over-engineered.

Community
  • 1
  • 1
Caridorc
  • 6,222
  • 2
  • 31
  • 46

1 Answers1

2

i think you can use

elements :: [a] -> Gen a

in combination with

listOf :: Gen a -> Gen [a]

so your String generator could look something like

vowels :: Gen String
vowels = listOf (elements "aeiou")
epsilonhalbe
  • 15,637
  • 5
  • 46
  • 74
  • I just saw your code in the pastebin - please name your functions `encode`/`decode` and have some `newtype`-aliases for `Brainf***` and `OoO` for `String` to go along with it. – epsilonhalbe Feb 28 '16 at 23:03
  • I am in fact worried about the quality of the code I wrote. I would be grateful if you could give me some advice at Codereview -> [Convert oOo to Brainfuck and viceversa](http://codereview.stackexchange.com/questions/121393/convert-ooo-to-brainfuck-and-viceversa) – Caridorc Feb 28 '16 at 23:16