-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A library for generating random string from a regular experession
--
-- With this package you can generate random strings from regular
-- expressions. If you are using QuickCheck, you can also check the
-- quickcheck-string-random package.
@package string-random
@version 0.1.4.2
-- | Parse the regular expression so that it can be used with the
-- Text.StringRandom module.
--
-- See String_random.js
module Text.StringRandom.Parser
-- | Abstract syntax tree of parsed regular expression
data Parsed
-- |
PClass :: [Char] -> Parsed
-- | X*, X{1,2}, X+, X?
PRange :: Int -> Maybe Int -> Parsed -> Parsed
-- | XYZ
PConcat :: [Parsed] -> Parsed
-- | X|Y|Z
PSelect :: [Parsed] -> Parsed
-- | (X)
PGrouped :: Int -> Parsed -> Parsed
-- | 1, 2, ..., 9
PBackward :: Int -> Parsed
-- | ^, $, b
PIgnored :: Parsed
-- | processParse parses the regular expression string and returns
-- an abstract syntax tree. If there is an error in the regular
-- expression, it returns the Left value.
processParse :: Text -> Either String Parsed
instance GHC.Classes.Eq Text.StringRandom.Parser.Parsed
instance GHC.Show.Show Text.StringRandom.Parser.Parsed
-- | Generate a random character string that matches the given regular
-- expression. This library ported String_random.js to Haskell.
--
--
--
-- import Text.StringRandom
--
-- main = do
-- ymd <- stringRandomIO "20\d\d-(1[0-2]|0[1-9])-(0[1-9]|1\d|2[0-8])"
-- print ymd -- "2048-12-08" etc.
--
--
-- See String_random.js
--
-- As with this package, there are random-strings in packages that
-- generate random strings, but this module is superior in the following
-- respects.
--
--
-- - The format of the string to be generated using regular
-- expressions
-- - You can change the random number generator (e.g. tf-random
-- package)
-- - With pure calculation without using IO monad.
--
module Text.StringRandom
-- | The stringRandomIO function generates random strings that match
-- the given regular expression. Regular expression is specified by
-- Text type. This function internally uses the random number
-- generator generated by newStdGen.
stringRandomIO :: Text -> IO Text
-- | The stringRandom function uses a specified random number
-- generator to generate a random string that matches a given regular
-- expression. An exception is raised if the regular expression can not
-- be parsed.
stringRandom :: RandomGen g => g -> Text -> Text
-- | The stringRandomWithError function behaves like the
-- stringRandom function, but notifies the error through the
-- Either monad.
stringRandomWithError :: RandomGen g => g -> Text -> Either String Text