-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Self-describing consumers/parsers; forms, cmd-line args, JSON, etc.
--
-- Self-describing consumers/parsers. See the README.md for more
-- information. It is currently EXPERIMENTAL.
@package descriptive
@version 0.3.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 :: Consumer s d a -> s -> (Result (Description d) a, s)
-- | Describe a consumer.
runDescription :: Consumer s d a -> s -> (Description d, s)
-- | 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 :: (s -> (Description d, s)) -> (s -> (Result (Description d) a, s)) -> Consumer s d a
consumerDesc :: Consumer s d a -> s -> (Description d, s)
consumerParse :: Consumer s d a -> s -> (Result (Description d) a, s)
-- | 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 consumer.
consumer :: (s -> (Description d, s)) -> (s -> (Result (Description d) a, s)) -> Consumer s d a
-- | Wrap a consumer with another consumer.
wrap :: (s -> (t -> (Description d, t)) -> (Description d, s)) -> (s -> (t -> (Description d, t)) -> (t -> (Result (Description d) a, t)) -> (Result (Description d) b, s)) -> Consumer t d a -> Consumer s d b
-- | Compose contiguous items into one sequence. Similar to
-- sequenceA.
sequencing :: [Consumer d s a] -> Consumer d s [a]
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
-- | Validate a form input with a description of what's required.
validate :: Text -> (a -> Maybe b) -> Consumer (Map Text Text) Form a -> Consumer (Map Text Text) Form b
-- | 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.
obj :: 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
-- | Consume a string.
string :: Text -> Consumer Value Doc Text
-- | Consume an integer.
integer :: Text -> Consumer Value Doc Integer
-- | Description of parseable things.
data Doc
Integer :: !Text -> Doc
Text :: !Text -> Doc
Struct :: !Text -> Doc
Key :: !Text -> Doc
instance Show Doc
instance Eq Doc