Shorter more readable toChar.

This commit is contained in:
Björn Buckwalter 2011-09-17 00:43:16 +08:00
parent 4ed740724e
commit 33ee15d56f

View File

@ -81,10 +81,7 @@ parseWaiRequest' env session' key' gen = Request gets'' cookies' env langs''' no
randomString :: RandomGen g => Int -> g -> String
randomString len = take len . map toChar . randomRs (0, 61)
where
toChar i
| i < 26 = toEnum $ i + fromEnum 'A'
| i < 52 = toEnum $ i + fromEnum 'a' - 26
| otherwise = toEnum $ i + fromEnum '0' - 52
toChar i = (['A'..'Z'] ++ ['a'..'z'] ++ ['0'..'9']) !! i
-- | A tuple containing both the POST parameters and submitted files.
type RequestBodyContents =