-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Declarative command-line parser with type-driven pattern matching. -- -- Declarative command-line parser with type-driven pattern matching. @package lambda-options @version 1.1.0.0 -- | Data definition for option keywords. module Text.LambdaOptions.Keyword -- | An option keyword, such as "--help" data Keyword Keyword :: [String] -> String -> String -> Keyword -- | All the aliases for this keyword. If no names are supplied, this -- keyword is alway matched. [kwNames] :: Keyword -> [String] -- | Text to describe the arguments to the option given by this keyword. [kwArgText] :: Keyword -> String -- | Text to describe the function of the option given by this keyword. [kwText] :: Keyword -> String -- | Convenience Keyword creation class. class ToKeyword a toKeyword :: ToKeyword a => a -> Keyword -- | Shorthand for toKeyword. kw :: ToKeyword a => a -> Keyword -- | Sets the kwArgText field in the keyword. Intended to be used -- infix: -- --
--   kw "--directory" `argText` "DIR" `text` "Write files to DIR."
--   
argText :: Keyword -> String -> Keyword -- | Sets the kwText field in the keyword. Intended to be used -- infix. -- --
--   kw "--quiet" `text` "Suppress message display."
--   
text :: Keyword -> String -> Keyword instance GHC.Classes.Ord Text.LambdaOptions.Keyword.Keyword instance GHC.Classes.Eq Text.LambdaOptions.Keyword.Keyword instance GHC.Show.Show Text.LambdaOptions.Keyword.Keyword instance Data.Data.Data Text.LambdaOptions.Keyword.Keyword instance Text.LambdaOptions.Keyword.ToKeyword Text.LambdaOptions.Keyword.Keyword instance Text.LambdaOptions.Keyword.ToKeyword GHC.Base.String instance Text.LambdaOptions.Keyword.ToKeyword [GHC.Base.String] instance Text.LambdaOptions.Keyword.ToKeyword () instance Data.String.IsString Text.LambdaOptions.Keyword.Keyword -- | Provides a configurable way to format help options for textual -- presentation. module Text.LambdaOptions.Formatter -- | User configuration for formatting. data FormatConfig FormatConfig :: Int -> FormatConfig [fmtMaxWidth] :: FormatConfig -> Int -- |
--   FormatConfig { fmtMaxWidth = 80 }
--   
defaultFormatConfig :: FormatConfig -- | Formats the given string with the given configuration. format :: FormatConfig -> String -> String -- | Formats the given keywords with the given configuration. formatKeywords :: FormatConfig -> [Keyword] -> String instance GHC.Classes.Ord Text.LambdaOptions.Formatter.FormatConfig instance GHC.Classes.Eq Text.LambdaOptions.Formatter.FormatConfig instance GHC.Read.Read Text.LambdaOptions.Formatter.FormatConfig instance GHC.Show.Show Text.LambdaOptions.Formatter.FormatConfig -- | Class used for parsing command-line options. module Text.LambdaOptions.Parseable -- | Class describing parseable values. Much like the Read class. class Parseable a -- | Given a sequence of strings, parse returns Nothing and -- the number of strings (not characters) consumed if the parse failed. -- Otherwise, parse returns Just the parsed value and the -- number of strings consumed. -- -- Element-wise, an entire string must be parsed in the sequence to be -- considered a successful parse. parse :: Parseable a => [String] -> (Maybe a, Int) -- | Turns a parser of a single string into a parser suitable for a -- Parseable instance. -- -- Useful for implementing a Parseable for a type with a -- Read instance by supplying readMaybe to this function. -- -- Note: The string is not tokenized in any way before -- being passed into the input parser. maybeParse :: (String -> Maybe a) -> [String] -> (Maybe a, Int) -- | Turns a parser of a single string into a parser suitable for a -- Parseable instance. -- -- Useful for implementing a Parseable for a type with a -- ReadBounded instance by supplying readBounded to this -- function. -- -- Note: The string is not tokenized in any way before -- being passed into the input parser. boundedParse :: (String -> BoundedRead a) -> [String] -> (Maybe a, Int) -- | Repeatedly applies parse the given number of times, -- accumulating the results. -- -- Useful for implementing new parsers. -- -- Example: -- --
--   data Point = Point Float Float Float
--   
--   instance Parseable Point where
--     parse args = case repeatedParse 3 args of
--       (Just [x,y,z], n) -> (Just (Point x y z), n)`
--       (Nothing, n) -> (Nothing, n)
--   
repeatedParse :: Parseable a => Int -> [String] -> (Maybe [a], Int) -- | Deprecated: Use maybeParse instead. -- | Deprecated: Use maybeParse instead. simpleParse :: (String -> Maybe a) -> [String] -> (Maybe a, Int) instance Text.LambdaOptions.Parseable.Parseable GHC.Types.Word instance Text.LambdaOptions.Parseable.Parseable GHC.Types.Int instance Text.LambdaOptions.Parseable.Parseable GHC.Integer.Type.Integer instance Text.LambdaOptions.Parseable.Parseable GHC.Types.Char instance Text.LambdaOptions.Parseable.Parseable GHC.Base.String instance Text.LambdaOptions.Parseable.Parseable GHC.Types.Float instance Text.LambdaOptions.Parseable.Parseable GHC.Types.Double instance Text.LambdaOptions.Parseable.Parseable a => Text.LambdaOptions.Parseable.Parseable (GHC.Maybe.Maybe a) instance (Text.LambdaOptions.Parseable.Parseable a, Text.LambdaOptions.Parseable.Parseable b) => Text.LambdaOptions.Parseable.Parseable (Data.Either.Either a b) instance GHC.TypeNats.KnownNat n => Text.LambdaOptions.Parseable.Parseable (Data.Proxy.Proxy n) instance GHC.TypeLits.KnownSymbol s => Text.LambdaOptions.Parseable.Parseable (Data.Proxy.Proxy s) instance Text.LambdaOptions.Parseable.Parseable GHC.TypeLits.SomeSymbol instance Text.LambdaOptions.Parseable.Parseable GHC.TypeNats.SomeNat instance Text.LambdaOptions.Parseable.Parseable () instance (Text.LambdaOptions.Parseable.Parseable a, Text.LambdaOptions.Parseable.Parseable b) => Text.LambdaOptions.Parseable.Parseable (a, b) instance (Text.LambdaOptions.Parseable.Parseable a, Text.LambdaOptions.Parseable.Parseable b, Text.LambdaOptions.Parseable.Parseable c) => Text.LambdaOptions.Parseable.Parseable (a, b, c) -- | Contains the core functionality for LambdaOptions. module Text.LambdaOptions.Core -- | Tries to parse the supplied options against input arguments. If -- successful, parsed option callback results are returned in -- Right. Otherwise OptionsError is returned in -- Left. -- -- Example program: -- --
--   import qualified System.Environment as Env
--   import qualified Text.LambdaOptions as L
--   
--   options :: L.Options (IO ())
--   options = do
--   
--     L.addOption
--       (L.kw ["--help", "-h"]
--       `L.text` "Display this help text.")
--       $ do
--         putStrLn "Usage:"
--         putStrLn $ L.getHelpDescription options
--   
--     L.addOption
--       (L.kw "--add"
--       `L.argText` "X Y"
--       `L.text` "Adds two Doubles and prints their sum.")
--       $ \x y -> do
--         print $ x + (y :: Double)
--   
--   main :: IO ()
--   main = do
--     args <- Env.getArgs
--     case L.runOptions options args of
--       Left e -> do
--         putStrLn $ L.prettyOptionsError e
--         putStrLn $ L.getHelpDescription options
--       Right results -> do
--         sequence_ results
--   
-- --
--   >>> :main --add 3 0.14
--   3.14
--   
--   >>> :main -h
--   Usage:
--        --add X Y               Adds two Doubles and prints their sum.
--    -h, --help                  Display this help text.
--   
--   >>> :main --add 0 1 --add 2 four
--   Bad input for `--add' at index 3: `four'
--        --add X Y               Adds two Doubles and prints their sum.
--    -h, --help                  Display this help text.
--   
runOptions :: Options r -> [String] -> Either OptionsError [r] -- | A context for parsing options. type Options r = OptionsM r () -- | A monad for parsing options. data OptionsM r a -- | Contains information about what went wrong during an unsuccessful -- options parse. data OptionsError ParseFailed :: String -> [String] -> Int -> Int -> OptionsError -- | Deprecated: Use prettyOptionsError instead. [parseFailedMessage] :: OptionsError -> String [parseFailedArgs] :: OptionsError -> [String] [parseFailedBeginArgsIndex] :: OptionsError -> Int [parseFailedEndArgsIndex] :: OptionsError -> Int -- | Pretty prints an OptionsError. prettyOptionsError :: OptionsError -> String -- | Describes the callback f to be called for a successfully -- parsed option. -- -- The function (or value) f can have any arity and ultimately -- returns a value with type r -- -- Each of the callback's arguments must have a type t which -- implements Parseable and Typeable. -- -- Think of this as the following constraint synonym: -- --
--   type OptionCallback r f = (f ~ ((Parseable t*, Typeable t*) => t0 -> t1 -> ... -> tN -> r))
--   
-- -- Example callbacks: -- --
--   f0 = putStrLn "Option parsed!" :: IO ()
--   f1 = put :: String -> State String ()
--   f2 = liftIO . print :: (MonadIO m) => Int -> m ()
--   f3 name year ratio = lift (print (name, year, ratio)) :: (MonadTrans m) => String -> Int -> Float -> m IO ()
--   f4 = 7 :: Int
--   f5 = (:) :: Double -> [Double] -> [Double]
--   
type OptionCallback r f = (GetOpaqueParsers r f, Wrap r f) -- | Adds the supplied option to the Options r context. -- -- If the keyword is matched and the types of the callback's parameters -- can successfully be parsed, the callback is called with the parsed -- arguments. addOption :: forall r f. OptionCallback r f => Keyword -> f -> Options r -- | Produces the help description given by the input options. getHelpDescription :: Options r -> String -- | Produces the Keywords inserted into the input options. getKeywords :: Options r -> [Keyword] instance GHC.Show.Show Text.LambdaOptions.Core.OptionsError instance GHC.Base.Functor (Text.LambdaOptions.Core.OptionsM r) instance GHC.Base.Applicative (Text.LambdaOptions.Core.OptionsM r) instance GHC.Base.Monad (Text.LambdaOptions.Core.OptionsM r) instance Control.Monad.State.Class.MonadState (Text.LambdaOptions.Core.OptionsState r) (Text.LambdaOptions.Core.OptionsM r) -- | Booly data type used for fine control of Bool parsers. module Text.LambdaOptions.Parseable.Booly -- | Data type used for parsing Bool values with various schemes. -- -- It can be useful to make an alias for this type: -- --
--   type B = Booly 'AllowWord 'DisallowLetter 'DisallowNumber 'LowerAll
--   
--   pattern B :: Bool -> B
--   pattern B x = Booly x
--   
--   b :: B -> Bool
--   b = unBooly
--   
data Booly (w :: BoolWord) (l :: BoolLetter) (n :: BoolNumber) (c :: BoolCasing) Booly :: Bool -> Booly [unBooly] :: Booly -> Bool -- | Controls word representation for Booly. data BoolWord -- | Disallow "true" and "false" word representations. DisallowWord :: BoolWord -- | Allow "true" and "false" word representations. AllowWord :: BoolWord -- | Controls letter representation for Booly. data BoolLetter -- | Disallow "t" and "f" letter representations. DisallowLetter :: BoolLetter -- | Allow "t" and "f" letter representations. AllowLetter :: BoolLetter -- | Controls number representation for Booly. data BoolNumber -- | Disallow number representations. DisallowNumber :: BoolNumber -- | Allow 0 and 1 number representations. AllowBit :: BoolNumber -- | Allow N >= 0 integer representations. 0 maps to -- False. N > 0 maps to True. AllowNatural :: BoolNumber -- | Allow any N integer representation. 0 maps to -- False. N /= 0 maps to True. AllowInteger :: BoolNumber -- | Controls required casing for Booly. data BoolCasing -- | Casing is completely ignored. IgnoreCase :: BoolCasing -- | Either casing satisfies a parse. OrCasing :: BoolCasing -> BoolCasing -> BoolCasing -- | Fully lowercase is required. LowerAll :: BoolCasing -- | Fully uppercase is required. UpperAll :: BoolCasing -- | The first letter must be uppercase. The rest must be lowercase. UpperHead :: BoolCasing -- | Parsers for the various BoolWord type constructors. class ReadBoolWord (w :: BoolWord) readBoolWord :: (ReadBoolWord w, BoolCasingVal c) => String -> Maybe (Booly w l n c) -- | Parsers for the various BoolLetter type constructors. class ReadBoolLetter (l :: BoolLetter) readBoolLetter :: (ReadBoolLetter l, BoolCasingVal c) => String -> Maybe (Booly w l n c) -- | Parsers for the various BoolNumber type constructors. class ReadBoolNumber (n :: BoolNumber) readBoolNumber :: ReadBoolNumber n => String -> Maybe (Booly w l n c) -- | Turns a type-level BoolCasing into a value-level one. class BoolCasingVal (c :: BoolCasing) boolCasingVal :: BoolCasingVal c => BoolCasing -- | Reads a Booly from a String. readBooly :: (ReadBoolWord w, ReadBoolLetter l, ReadBoolNumber n, BoolCasingVal c) => String -> Maybe (Booly w l n c) instance GHC.Classes.Ord (Text.LambdaOptions.Parseable.Booly.Booly w l n c) instance GHC.Classes.Eq (Text.LambdaOptions.Parseable.Booly.Booly w l n c) instance GHC.Read.Read (Text.LambdaOptions.Parseable.Booly.Booly w l n c) instance GHC.Show.Show (Text.LambdaOptions.Parseable.Booly.Booly w l n c) instance (Data.Typeable.Internal.Typeable w, Data.Typeable.Internal.Typeable l, Data.Typeable.Internal.Typeable n, Data.Typeable.Internal.Typeable c) => Data.Data.Data (Text.LambdaOptions.Parseable.Booly.Booly w l n c) instance Text.LambdaOptions.Parseable.Booly.ReadBoolNumber 'Text.LambdaOptions.Parseable.Booly.DisallowNumber instance Text.LambdaOptions.Parseable.Booly.ReadBoolNumber 'Text.LambdaOptions.Parseable.Booly.AllowBit instance Text.LambdaOptions.Parseable.Booly.ReadBoolNumber 'Text.LambdaOptions.Parseable.Booly.AllowNatural instance Text.LambdaOptions.Parseable.Booly.ReadBoolNumber 'Text.LambdaOptions.Parseable.Booly.AllowInteger instance (Text.LambdaOptions.Parseable.Booly.ReadBoolWord w, Text.LambdaOptions.Parseable.Booly.ReadBoolLetter l, Text.LambdaOptions.Parseable.Booly.ReadBoolNumber n, Text.LambdaOptions.Parseable.Booly.BoolCasingVal c) => Text.LambdaOptions.Parseable.Parseable (Text.LambdaOptions.Parseable.Booly.Booly w l n c) instance Text.LambdaOptions.Parseable.Booly.ReadBoolLetter 'Text.LambdaOptions.Parseable.Booly.DisallowLetter instance Text.LambdaOptions.Parseable.Booly.ReadBoolLetter 'Text.LambdaOptions.Parseable.Booly.AllowLetter instance Text.LambdaOptions.Parseable.Booly.ReadBoolWord 'Text.LambdaOptions.Parseable.Booly.DisallowWord instance Text.LambdaOptions.Parseable.Booly.ReadBoolWord 'Text.LambdaOptions.Parseable.Booly.AllowWord instance (Text.LambdaOptions.Parseable.Booly.BoolCasingVal a, Text.LambdaOptions.Parseable.Booly.BoolCasingVal b) => Text.LambdaOptions.Parseable.Booly.BoolCasingVal ('Text.LambdaOptions.Parseable.Booly.OrCasing a b) instance Text.LambdaOptions.Parseable.Booly.BoolCasingVal 'Text.LambdaOptions.Parseable.Booly.IgnoreCase instance Text.LambdaOptions.Parseable.Booly.BoolCasingVal 'Text.LambdaOptions.Parseable.Booly.LowerAll instance Text.LambdaOptions.Parseable.Booly.BoolCasingVal 'Text.LambdaOptions.Parseable.Booly.UpperAll instance Text.LambdaOptions.Parseable.Booly.BoolCasingVal 'Text.LambdaOptions.Parseable.Booly.UpperHead -- | List newtype wrapper that can be pattern matched against for parsing. module Text.LambdaOptions.Parseable.List -- | A simple wrapper over [a]. Used to avoid overlapping -- instances for Parseable [a] and Parseable String. newtype List a List :: [a] -> List a [unList] :: List a -> [a] instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.LambdaOptions.Parseable.List.List a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.LambdaOptions.Parseable.List.List a) instance GHC.Read.Read a => GHC.Read.Read (Text.LambdaOptions.Parseable.List.List a) instance GHC.Show.Show a => GHC.Show.Show (Text.LambdaOptions.Parseable.List.List a) instance Data.Data.Data a => Data.Data.Data (Text.LambdaOptions.Parseable.List.List a) instance Text.LambdaOptions.Parseable.Parseable a => Text.LambdaOptions.Parseable.Parseable (Text.LambdaOptions.Parseable.List.List a) -- | Declarative command-line parser using type-driven pattern matching. module Text.LambdaOptions -- | View my source code to see example. module Text.LambdaOptions.Example.Example_6_SubOptions -- | Try with these succeeding examples: -- --
--   :main help
--   :main help clone
--   :main clone some-repo
--   :main clone some-repo some-dir
--   :main clone --binary some-repo
--   
main :: IO () instance GHC.Show.Show Text.LambdaOptions.Example.Example_6_SubOptions.SourceControlOption -- | View my source code to see example. module Text.LambdaOptions.Example.Example_5_Repl -- | Try with these succeeding examples: -- --
--   :main
--   >> help
--   >> product 11 5 7.12
--   >> sum -1.23 1.23
--   >> quit
--   
main :: IO () -- | View my source code to see example. module Text.LambdaOptions.Example.Example_4_Booly -- | Try with these succeeding examples: -- --
--   :main --and true false
--   :main --and TRUE FALSE
--   :main --and 1 0
--   :main --and true 0 --or 1 TRUE
--   
-- -- Also try with these failing examples: -- --
--   :main --and true
--   :main --and t f
--   :main --and 0 2
--   :main --and True False
--   
main :: IO () -- | View my source code to see example. module Text.LambdaOptions.Example.Example_3_Record -- | Try with these succeeding examples: -- --
--   :main --foo 1 abc
--   :main --bar
--   :main --bar 4 5 6
--   :main --baz
--   :main --foo 1 abc --bar 4 5 6 --baz
--   :main --baz --bar 4 5 6 --foo 1 abc
--   
-- -- Also try with these failing examples: -- --
--   :main --foo abc
--   :main --foo 1.5 abc
--   :main --bar a b c
--   
main :: IO () instance GHC.Show.Show Text.LambdaOptions.Example.Example_3_Record.Options -- | View my source code to see example. module Text.LambdaOptions.Example.Example_2_Constructors -- | Try with these succeeding examples: -- --
--   :main --foo 1 abc
--   :main --bar
--   :main --bar 4 5 6
--   :main --baz
--   :main --foo 1 abc --bar 4 5 6 --baz
--   :main --baz --bar 4 5 6 --foo 1 abc
--   
-- -- Also try with these failing examples: -- --
--   :main --foo abc
--   :main --foo 1.5 abc
--   :main --bar a b c
--   
main :: IO () instance GHC.Show.Show Text.LambdaOptions.Example.Example_2_Constructors.Option -- | View my source code to see example. module Text.LambdaOptions.Example.Example_1_Simple -- | Try with these succeeding examples: -- --
--   :main --help
--   :main --add 1 2
--   :main --add 3 4 --add 5 6
--   :main --add -1 3.14
--   
-- -- Also try with these failing examples: -- --
--   :main --add 0
--   :main --add 1 2 3
--   :main --add 123
--   :main --add True 0
--   :main --add 0 True
--   
main :: IO ()