-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Self-describing consumers/parsers; forms, cmd-line args, JSON, etc.
--
@package descriptive
@version 0.6.0
-- | Descriptive parsers.
module Descriptive
-- | Run a consumer.
consume :: Consumer s d a -> s -> Result (Description d) a
-- | Describe a consumer.
describe :: Consumer s d a -> s -> Description d
-- | Run a consumer.
runConsumer :: Monad m => Consumer s d a -> StateT s m (Result (Description d) a)
-- | Describe a consumer.
runDescription :: Monad m => Consumer s d a -> StateT s m (Description d)
-- | Description of a consumable thing.
data Description a
Unit :: !a -> Description a
Bounded :: !Integer -> !Bound -> !(Description a) -> Description a
And :: !(Description a) -> !(Description a) -> Description a
Or :: !(Description a) -> !(Description a) -> Description a
Sequence :: ![Description a] -> Description a
Wrap :: a -> !(Description a) -> Description a
None :: Description a
-- | The bounds of a many-consumable thing.
data Bound
NaturalBound :: !Integer -> Bound
UnlimitedBound :: Bound
-- | A consumer.
data Consumer s d a
Consumer :: (forall m. Monad m => StateT s m (Description d)) -> (forall m. Monad m => StateT s m (Result (Description d) a)) -> Consumer s d a
consumerDesc :: Consumer s d a -> forall m. Monad m => StateT s m (Description d)
consumerParse :: Consumer s d a -> forall m. Monad m => StateT s m (Result (Description d) a)
-- | Some result.
data Result e a
-- | The whole process failed.
Failed :: e -> Result e a
-- | The whole process succeeded.
Succeeded :: a -> Result e a
-- | There were errors but we continued to collect all the errors.
Continued :: e -> Result e a
-- | Make a self-describing consumer.
consumer :: (forall m. Monad m => StateT s m (Description d)) -> (forall m. Monad m => StateT s m (Result (Description d) a)) -> Consumer s d a
-- | Wrap a consumer with another consumer. The type looks more
-- intimidating than it actually is. The source code is trivial. It
-- simply allows for a way to transform the type of the state.
wrap :: (forall m. Monad m => StateT t m (Description d) -> StateT s m (Description d)) -> (forall m. Monad m => StateT t m (Description d) -> StateT t m (Result (Description d) a) -> StateT s m (Result (Description d) b)) -> Consumer t d a -> Consumer s d b
-- | Add validation to a consumer.
validate :: d -> (forall m. MonadState s m => a -> m (Maybe b)) -> Consumer s d a -> Consumer s d b
instance Show Bound
instance Eq Bound
instance Show a => Show (Description a)
instance Eq a => Eq (Description a)
instance (Show e, Show a) => Show (Result e a)
instance (Eq e, Eq a) => Eq (Result e a)
instance (Ord e, Ord a) => Ord (Result e a)
instance Monoid a => Monoid (Consumer s d a)
instance Monoid a => Monoid (Result (Description d) a)
instance Alternative (Consumer s d)
instance Applicative (Consumer s d)
instance Functor (Consumer s d)
instance Bifunctor Result
instance Monoid (Description d)
-- | Consuming form a list of characters.
module Descriptive.Char
-- | Consume any character.
anyChar :: Consumer [Char] Text Char
-- | A character consumer.
char :: Char -> Consumer [Char] Text Char
-- | A string consumer.
string :: [Char] -> Consumer [Char] Text [Char]
-- | Validating form with named inputs.
module Descriptive.Form
-- | Consume any input value.
input :: Text -> Consumer (Map Text Text) Form Text
-- | Form descriptor.
data Form
Input :: !Text -> Form
Constraint :: !Text -> Form
instance Show Form
instance Eq Form
-- | Validating indexed formlet with auto-generated input names.
module Descriptive.Formlet
-- | Consume any character.
indexed :: Consumer FormletState Formlet Text
-- | State used when running a formlet.
data FormletState
FormletState :: (Map Integer Text) -> !Integer -> FormletState
formletMap :: FormletState -> (Map Integer Text)
formletIndex :: FormletState -> !Integer
-- | Description of a formlet.
data Formlet
Index :: !Integer -> Formlet
Constrained :: !Text -> Formlet
instance Show Formlet
instance Eq Formlet
instance Show FormletState
instance Eq FormletState
-- | Command-line options parser.
module Descriptive.Options
-- | Find a value flag which must succeed. Removes it from the argument
-- list if it succeeds.
flag :: Text -> Text -> v -> Consumer [Text] (Option a) v
-- | Find a boolean flag. Always succeeds. Omission counts as False.
-- Removes it from the argument list if it returns True.
switch :: Text -> Text -> Consumer [Text] (Option a) Bool
-- | Find an argument prefixed by -X. Removes it from the argument list
-- when it succeeds.
prefix :: Text -> Text -> Consumer [Text] (Option a) Text
-- | Find a named argument e.g. --name value. Removes it from the
-- argument list when it succeeds.
arg :: Text -> Text -> Consumer [Text] (Option a) Text
-- | Consume one argument from the argument list and pops it from the start
-- of the list.
anyString :: Text -> Consumer [Text] (Option a) Text
-- | Consume one argument from the argument list which must match the given
-- string, and also pops it off the argument list.
constant :: Text -> Text -> v -> Consumer [Text] (Option a) v
-- | If the consumer succeeds, stops the whole parser and returns
-- Stopped immediately.
stop :: Consumer [Text] (Option a) a -> Consumer [Text] (Option a) ()
-- | Description of a commandline option.
data Option a
AnyString :: !Text -> Option a
Constant :: !Text -> !Text -> Option a
Flag :: !Text -> !Text -> Option a
Arg :: !Text -> !Text -> Option a
Prefix :: !Text -> !Text -> Option a
Stops :: Option a
Stopped :: !a -> Option a
-- | Make a text description of the command line options.
textDescription :: Description (Option a) -> Text
-- | Make a text description of an option.
textOpt :: (Option a) -> Text
instance Show a => Show (Option a)
instance Eq a => Eq (Option a)
-- | A JSON API which describes itself.
module Descriptive.JSON
-- | Consume an object.
object :: Text -> Consumer Object Doc a -> Consumer Value Doc a
-- | Consume from object at the given key.
key :: Text -> Consumer Value Doc a -> Consumer Object Doc a
-- | Optionally consume from object at the given key, only if it exists.
keyMaybe :: Text -> Consumer Value Doc a -> Consumer Object Doc (Maybe a)
-- | Consume an array.
array :: Text -> Consumer Value Doc a -> Consumer Value Doc (Vector a)
-- | Consume a string.
string :: Text -> Consumer Value Doc Text
-- | Consume an integer.
integer :: Text -> Consumer Value Doc Integer
-- | Consume an double.
double :: Text -> Consumer Value Doc Double
-- | Parse a boolean.
bool :: Text -> Consumer Value Doc Bool
-- | Expect null.
null :: Text -> Consumer Value Doc ()
-- | Wrap a consumer with a label e.g. a type tag.
label :: Text -> Consumer s Doc a -> Consumer s Doc a
-- | Wrap a consumer with some handy information.
info :: Text -> Consumer s Doc a -> Consumer s Doc a
-- | Description of parseable things.
data Doc
Integer :: !Text -> Doc
Double :: !Text -> Doc
Text :: !Text -> Doc
Boolean :: !Text -> Doc
Null :: !Text -> Doc
Object :: !Text -> Doc
Key :: !Text -> Doc
Array :: !Text -> Doc
Label :: !Text -> Doc
Info :: !Text -> Doc
instance Typeable Doc
instance Eq Doc
instance Show Doc
instance Data Doc