File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,9 @@ module Data.Char.Gen where
22
33import Prelude
44
5- import Control.Monad.Gen (class MonadGen , chooseInt )
5+ import Control.Monad.Gen (class MonadGen , chooseInt , oneOf )
66import Data.Char as C
7+ import Data.NonEmpty ((:|))
78
89-- | Generates a character of the Unicode basic multilingual plain.
910genUnicodeChar :: forall m . MonadGen m => m Char
@@ -20,3 +21,15 @@ genAsciiChar' = C.fromCharCode <$> chooseInt 0 127
2021-- | Generates a character that is a numeric digit.
2122genDigitChar :: forall m . MonadGen m => m Char
2223genDigitChar = C .fromCharCode <$> chooseInt 48 57
24+
25+ -- | Generates a character from the basic latin alphabet.
26+ genAlpha :: forall m . MonadGen m => m Char
27+ genAlpha = oneOf (genAlphaLowercase :| [genAlphaUppercase])
28+
29+ -- | Generates a lowercase character from the basic latin alphabet.
30+ genAlphaLowercase :: forall m . MonadGen m => m Char
31+ genAlphaLowercase = C .fromCharCode <$> chooseInt 97 122
32+
33+ -- | Generates an uppercase character from the basic latin alphabet.
34+ genAlphaUppercase :: forall m . MonadGen m => m Char
35+ genAlphaUppercase = C .fromCharCode <$> chooseInt 65 90
You can’t perform that action at this time.
0 commit comments