File tree 1 file changed +14
-1
lines changed 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
2
2
3
3
import Prelude
4
4
5
- import Control.Monad.Gen (class MonadGen , chooseInt )
5
+ import Control.Monad.Gen (class MonadGen , chooseInt , oneOf )
6
6
import Data.Char as C
7
+ import Data.NonEmpty ((:|))
7
8
8
9
-- | Generates a character of the Unicode basic multilingual plain.
9
10
genUnicodeChar :: forall m . MonadGen m => m Char
@@ -20,3 +21,15 @@ genAsciiChar' = C.fromCharCode <$> chooseInt 0 127
20
21
-- | Generates a character that is a numeric digit.
21
22
genDigitChar :: forall m . MonadGen m => m Char
22
23
genDigitChar = 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