{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Fake.Utils where
import Data.String
import Data.Text (Text)
import GHC.Exts
import Fake.Combinators
import Fake.Types
numerify :: Char -> FGen Char
numerify :: Char -> FGen Char
numerify Char
'#' = FGen Char
fakeDigit
numerify Char
'%' = FGen Char
fakeDigitNonzero
numerify Char
'!' = FGen Char
fakeDigit
numerify Char
'@' = FGen Char
fakeDigitNonzero
numerify Char
c = Char -> FGen Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
c
lexify :: [Char] -> Char -> FGen Char
lexify :: [Char] -> Char -> FGen Char
lexify [Char]
letters Char
'?' = [Char] -> FGen Char
forall a. [a] -> FGen a
elements [Char]
letters
lexify [Char]
_ Char
c = Char -> FGen Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
c
bothify :: [Char] -> Char -> FGen Char
bothify :: [Char] -> Char -> FGen Char
bothify [Char]
_ Char
'#' = FGen Char
fakeDigit
bothify [Char]
_ Char
'%' = FGen Char
fakeDigitNonzero
bothify [Char]
_ Char
'!' = FGen Char
fakeDigit
bothify [Char]
_ Char
'@' = FGen Char
fakeDigitNonzero
bothify [Char]
letters Char
'?' = [Char] -> FGen Char
forall a. [a] -> FGen a
elements [Char]
letters
bothify [Char]
_ Char
c = Char -> FGen Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
c
newtype NumberScheme = NumberScheme { NumberScheme -> Text
unNumberScheme :: Text }
deriving (NumberScheme -> NumberScheme -> Bool
(NumberScheme -> NumberScheme -> Bool)
-> (NumberScheme -> NumberScheme -> Bool) -> Eq NumberScheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NumberScheme -> NumberScheme -> Bool
$c/= :: NumberScheme -> NumberScheme -> Bool
== :: NumberScheme -> NumberScheme -> Bool
$c== :: NumberScheme -> NumberScheme -> Bool
Eq,Eq NumberScheme
Eq NumberScheme
-> (NumberScheme -> NumberScheme -> Ordering)
-> (NumberScheme -> NumberScheme -> Bool)
-> (NumberScheme -> NumberScheme -> Bool)
-> (NumberScheme -> NumberScheme -> Bool)
-> (NumberScheme -> NumberScheme -> Bool)
-> (NumberScheme -> NumberScheme -> NumberScheme)
-> (NumberScheme -> NumberScheme -> NumberScheme)
-> Ord NumberScheme
NumberScheme -> NumberScheme -> Bool
NumberScheme -> NumberScheme -> Ordering
NumberScheme -> NumberScheme -> NumberScheme
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: NumberScheme -> NumberScheme -> NumberScheme
$cmin :: NumberScheme -> NumberScheme -> NumberScheme
max :: NumberScheme -> NumberScheme -> NumberScheme
$cmax :: NumberScheme -> NumberScheme -> NumberScheme
>= :: NumberScheme -> NumberScheme -> Bool
$c>= :: NumberScheme -> NumberScheme -> Bool
> :: NumberScheme -> NumberScheme -> Bool
$c> :: NumberScheme -> NumberScheme -> Bool
<= :: NumberScheme -> NumberScheme -> Bool
$c<= :: NumberScheme -> NumberScheme -> Bool
< :: NumberScheme -> NumberScheme -> Bool
$c< :: NumberScheme -> NumberScheme -> Bool
compare :: NumberScheme -> NumberScheme -> Ordering
$ccompare :: NumberScheme -> NumberScheme -> Ordering
$cp1Ord :: Eq NumberScheme
Ord,ReadPrec [NumberScheme]
ReadPrec NumberScheme
Int -> ReadS NumberScheme
ReadS [NumberScheme]
(Int -> ReadS NumberScheme)
-> ReadS [NumberScheme]
-> ReadPrec NumberScheme
-> ReadPrec [NumberScheme]
-> Read NumberScheme
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NumberScheme]
$creadListPrec :: ReadPrec [NumberScheme]
readPrec :: ReadPrec NumberScheme
$creadPrec :: ReadPrec NumberScheme
readList :: ReadS [NumberScheme]
$creadList :: ReadS [NumberScheme]
readsPrec :: Int -> ReadS NumberScheme
$creadsPrec :: Int -> ReadS NumberScheme
Read,Int -> NumberScheme -> ShowS
[NumberScheme] -> ShowS
NumberScheme -> [Char]
(Int -> NumberScheme -> ShowS)
-> (NumberScheme -> [Char])
-> ([NumberScheme] -> ShowS)
-> Show NumberScheme
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [NumberScheme] -> ShowS
$cshowList :: [NumberScheme] -> ShowS
show :: NumberScheme -> [Char]
$cshow :: NumberScheme -> [Char]
showsPrec :: Int -> NumberScheme -> ShowS
$cshowsPrec :: Int -> NumberScheme -> ShowS
Show,[Char] -> NumberScheme
([Char] -> NumberScheme) -> IsString NumberScheme
forall a. ([Char] -> a) -> IsString a
fromString :: [Char] -> NumberScheme
$cfromString :: [Char] -> NumberScheme
IsString)
fakeNumberScheme :: NumberScheme -> FGen Text
fakeNumberScheme :: NumberScheme -> FGen Text
fakeNumberScheme (NumberScheme Text
t) = ([Char] -> Text) -> FGen [Char] -> FGen Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Char] -> Text
forall l. IsList l => [Item l] -> l
fromList (FGen [Char] -> FGen Text) -> FGen [Char] -> FGen Text
forall a b. (a -> b) -> a -> b
$ (Char -> FGen Char) -> [Char] -> FGen [Char]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Char -> FGen Char
numerify ([Char] -> FGen [Char]) -> [Char] -> FGen [Char]
forall a b. (a -> b) -> a -> b
$ Text -> [Item Text]
forall l. IsList l => l -> [Item l]
toList Text
t
newtype AlphaScheme = AlphaScheme { AlphaScheme -> Text
unAlphaScheme :: Text }
deriving (AlphaScheme -> AlphaScheme -> Bool
(AlphaScheme -> AlphaScheme -> Bool)
-> (AlphaScheme -> AlphaScheme -> Bool) -> Eq AlphaScheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlphaScheme -> AlphaScheme -> Bool
$c/= :: AlphaScheme -> AlphaScheme -> Bool
== :: AlphaScheme -> AlphaScheme -> Bool
$c== :: AlphaScheme -> AlphaScheme -> Bool
Eq,Eq AlphaScheme
Eq AlphaScheme
-> (AlphaScheme -> AlphaScheme -> Ordering)
-> (AlphaScheme -> AlphaScheme -> Bool)
-> (AlphaScheme -> AlphaScheme -> Bool)
-> (AlphaScheme -> AlphaScheme -> Bool)
-> (AlphaScheme -> AlphaScheme -> Bool)
-> (AlphaScheme -> AlphaScheme -> AlphaScheme)
-> (AlphaScheme -> AlphaScheme -> AlphaScheme)
-> Ord AlphaScheme
AlphaScheme -> AlphaScheme -> Bool
AlphaScheme -> AlphaScheme -> Ordering
AlphaScheme -> AlphaScheme -> AlphaScheme
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AlphaScheme -> AlphaScheme -> AlphaScheme
$cmin :: AlphaScheme -> AlphaScheme -> AlphaScheme
max :: AlphaScheme -> AlphaScheme -> AlphaScheme
$cmax :: AlphaScheme -> AlphaScheme -> AlphaScheme
>= :: AlphaScheme -> AlphaScheme -> Bool
$c>= :: AlphaScheme -> AlphaScheme -> Bool
> :: AlphaScheme -> AlphaScheme -> Bool
$c> :: AlphaScheme -> AlphaScheme -> Bool
<= :: AlphaScheme -> AlphaScheme -> Bool
$c<= :: AlphaScheme -> AlphaScheme -> Bool
< :: AlphaScheme -> AlphaScheme -> Bool
$c< :: AlphaScheme -> AlphaScheme -> Bool
compare :: AlphaScheme -> AlphaScheme -> Ordering
$ccompare :: AlphaScheme -> AlphaScheme -> Ordering
$cp1Ord :: Eq AlphaScheme
Ord,ReadPrec [AlphaScheme]
ReadPrec AlphaScheme
Int -> ReadS AlphaScheme
ReadS [AlphaScheme]
(Int -> ReadS AlphaScheme)
-> ReadS [AlphaScheme]
-> ReadPrec AlphaScheme
-> ReadPrec [AlphaScheme]
-> Read AlphaScheme
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlphaScheme]
$creadListPrec :: ReadPrec [AlphaScheme]
readPrec :: ReadPrec AlphaScheme
$creadPrec :: ReadPrec AlphaScheme
readList :: ReadS [AlphaScheme]
$creadList :: ReadS [AlphaScheme]
readsPrec :: Int -> ReadS AlphaScheme
$creadsPrec :: Int -> ReadS AlphaScheme
Read,Int -> AlphaScheme -> ShowS
[AlphaScheme] -> ShowS
AlphaScheme -> [Char]
(Int -> AlphaScheme -> ShowS)
-> (AlphaScheme -> [Char])
-> ([AlphaScheme] -> ShowS)
-> Show AlphaScheme
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [AlphaScheme] -> ShowS
$cshowList :: [AlphaScheme] -> ShowS
show :: AlphaScheme -> [Char]
$cshow :: AlphaScheme -> [Char]
showsPrec :: Int -> AlphaScheme -> ShowS
$cshowsPrec :: Int -> AlphaScheme -> ShowS
Show,[Char] -> AlphaScheme
([Char] -> AlphaScheme) -> IsString AlphaScheme
forall a. ([Char] -> a) -> IsString a
fromString :: [Char] -> AlphaScheme
$cfromString :: [Char] -> AlphaScheme
IsString)
fakeAlphaScheme :: AlphaScheme -> FGen Text
fakeAlphaScheme :: AlphaScheme -> FGen Text
fakeAlphaScheme (AlphaScheme Text
t) =
([Char] -> Text) -> FGen [Char] -> FGen Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Char] -> Text
forall l. IsList l => [Item l] -> l
fromList (FGen [Char] -> FGen Text) -> FGen [Char] -> FGen Text
forall a b. (a -> b) -> a -> b
$ (Char -> FGen Char) -> [Char] -> FGen [Char]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ([Char] -> Char -> FGen Char
lexify [Char
'a'..Char
'z']) ([Char] -> FGen [Char]) -> [Char] -> FGen [Char]
forall a b. (a -> b) -> a -> b
$ Text -> [Item Text]
forall l. IsList l => l -> [Item l]
toList Text
t
newtype AlphaNumScheme = AlphaNumScheme { AlphaNumScheme -> Text
unAlphaNumScheme :: Text }
deriving (AlphaNumScheme -> AlphaNumScheme -> Bool
(AlphaNumScheme -> AlphaNumScheme -> Bool)
-> (AlphaNumScheme -> AlphaNumScheme -> Bool) -> Eq AlphaNumScheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlphaNumScheme -> AlphaNumScheme -> Bool
$c/= :: AlphaNumScheme -> AlphaNumScheme -> Bool
== :: AlphaNumScheme -> AlphaNumScheme -> Bool
$c== :: AlphaNumScheme -> AlphaNumScheme -> Bool
Eq,Eq AlphaNumScheme
Eq AlphaNumScheme
-> (AlphaNumScheme -> AlphaNumScheme -> Ordering)
-> (AlphaNumScheme -> AlphaNumScheme -> Bool)
-> (AlphaNumScheme -> AlphaNumScheme -> Bool)
-> (AlphaNumScheme -> AlphaNumScheme -> Bool)
-> (AlphaNumScheme -> AlphaNumScheme -> Bool)
-> (AlphaNumScheme -> AlphaNumScheme -> AlphaNumScheme)
-> (AlphaNumScheme -> AlphaNumScheme -> AlphaNumScheme)
-> Ord AlphaNumScheme
AlphaNumScheme -> AlphaNumScheme -> Bool
AlphaNumScheme -> AlphaNumScheme -> Ordering
AlphaNumScheme -> AlphaNumScheme -> AlphaNumScheme
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AlphaNumScheme -> AlphaNumScheme -> AlphaNumScheme
$cmin :: AlphaNumScheme -> AlphaNumScheme -> AlphaNumScheme
max :: AlphaNumScheme -> AlphaNumScheme -> AlphaNumScheme
$cmax :: AlphaNumScheme -> AlphaNumScheme -> AlphaNumScheme
>= :: AlphaNumScheme -> AlphaNumScheme -> Bool
$c>= :: AlphaNumScheme -> AlphaNumScheme -> Bool
> :: AlphaNumScheme -> AlphaNumScheme -> Bool
$c> :: AlphaNumScheme -> AlphaNumScheme -> Bool
<= :: AlphaNumScheme -> AlphaNumScheme -> Bool
$c<= :: AlphaNumScheme -> AlphaNumScheme -> Bool
< :: AlphaNumScheme -> AlphaNumScheme -> Bool
$c< :: AlphaNumScheme -> AlphaNumScheme -> Bool
compare :: AlphaNumScheme -> AlphaNumScheme -> Ordering
$ccompare :: AlphaNumScheme -> AlphaNumScheme -> Ordering
$cp1Ord :: Eq AlphaNumScheme
Ord,ReadPrec [AlphaNumScheme]
ReadPrec AlphaNumScheme
Int -> ReadS AlphaNumScheme
ReadS [AlphaNumScheme]
(Int -> ReadS AlphaNumScheme)
-> ReadS [AlphaNumScheme]
-> ReadPrec AlphaNumScheme
-> ReadPrec [AlphaNumScheme]
-> Read AlphaNumScheme
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlphaNumScheme]
$creadListPrec :: ReadPrec [AlphaNumScheme]
readPrec :: ReadPrec AlphaNumScheme
$creadPrec :: ReadPrec AlphaNumScheme
readList :: ReadS [AlphaNumScheme]
$creadList :: ReadS [AlphaNumScheme]
readsPrec :: Int -> ReadS AlphaNumScheme
$creadsPrec :: Int -> ReadS AlphaNumScheme
Read,Int -> AlphaNumScheme -> ShowS
[AlphaNumScheme] -> ShowS
AlphaNumScheme -> [Char]
(Int -> AlphaNumScheme -> ShowS)
-> (AlphaNumScheme -> [Char])
-> ([AlphaNumScheme] -> ShowS)
-> Show AlphaNumScheme
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [AlphaNumScheme] -> ShowS
$cshowList :: [AlphaNumScheme] -> ShowS
show :: AlphaNumScheme -> [Char]
$cshow :: AlphaNumScheme -> [Char]
showsPrec :: Int -> AlphaNumScheme -> ShowS
$cshowsPrec :: Int -> AlphaNumScheme -> ShowS
Show,[Char] -> AlphaNumScheme
([Char] -> AlphaNumScheme) -> IsString AlphaNumScheme
forall a. ([Char] -> a) -> IsString a
fromString :: [Char] -> AlphaNumScheme
$cfromString :: [Char] -> AlphaNumScheme
IsString)
fakeAlphaNumScheme :: AlphaNumScheme -> FGen Text
fakeAlphaNumScheme :: AlphaNumScheme -> FGen Text
fakeAlphaNumScheme (AlphaNumScheme Text
t) =
([Char] -> Text) -> FGen [Char] -> FGen Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Char] -> Text
forall l. IsList l => [Item l] -> l
fromList (FGen [Char] -> FGen Text) -> FGen [Char] -> FGen Text
forall a b. (a -> b) -> a -> b
$ (Char -> FGen Char) -> [Char] -> FGen [Char]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ([Char] -> Char -> FGen Char
bothify [Char
'a'..Char
'z']) ([Char] -> FGen [Char]) -> [Char] -> FGen [Char]
forall a b. (a -> b) -> a -> b
$ Text -> [Item Text]
forall l. IsList l => l -> [Item l]
toList Text
t