Created
September 1, 2012 13:15
-
-
Save dtchepak/3572960 to your computer and use it in GitHub Desktop.
random strings (w/out quickcheck)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
randomChar :: (RandomGen g) => State g Char | |
randomChar = state $ randomR ('a','z') | |
randomStringWithLength :: (RandomGen g) => Int -> State g String | |
randomStringWithLength i = replicateM i randomChar | |
randomString :: (RandomGen g) => State g String | |
randomString = state $ \g -> | |
let (charsToGen, g') = randomR (1,10) g | |
in runState (randomStringWithLength charsToGen) g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment