-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple command line argument parsing -- -- ReadArgs provides the readArgs IO action, which lets you tell -- the compiler to parse the command line arguments to fit the type -- signature you give. -- -- For example (a :: Int, b :: String, c :: Float) <- -- readArgs would parse the first runtime argument as an -- Int, the second as a String (no quotes required) and -- the third as a Float. -- -- If the runtime arguments are incompatible with the type signature, -- then a simple usage statement is given of the types needed. -- -- Continuing the previous example, if it was used in a program named -- Example, the error message for the above action would be: -- --
--   usage: Example Int String Float
--   
-- -- Any type that has both Typeable and Read instances -- can be used. Char, String, and Text are -- handled specially so that command line arguments for both do not -- require quotes (as their Read instances do). A special -- instance is provided for FilePath so that no constructor or -- quotes are required. -- -- readArgs also supports optional arguments and variadic -- arguments. Optional arguments are specified using Maybe, and -- variadic arguments using a list. (a :: Int, b :: Maybe String, c -- :: [Float]) <- readArgs would successfully parse any of the -- following sets of command line arguments: -- --
--   Example 1
--   Example 1 2 3 4
--   Example 1 foo
--   Example 1 foo 2 3 4
--   
-- -- But not -- --
--   Example
--   Example foo
--   Example 1.0
--   
-- -- Usage statements for optional and variadic arguments use command-line -- parlance: -- --
--   usage: Example Int [String] [Float..]
--   
-- -- Note that both optional and variadic parsers are greedy by default (so -- Example 1 2 3 4 was parsed as (1, 2, -- [3.0,4.0]). They may both be made non-greedy through use of the -- NonGreedy constructor: -- --
--   ( a :: Int
--   , NonGreedy b :: NonGreedy Maybe String
--   , NonGreedy c :: NonGreedy [] Float
--   ) <- readArgs
--   
@package ReadArgs @version 1.2 module ReadArgs -- | parse the desired argument tuple from the command line or print a -- simple usage statment and quit readArgs :: ArgumentTuple a => IO a -- | read args from the given strings or print a simple usage statment and -- quit (so you can do option parsing first) readArgsFrom :: ArgumentTuple a => [String] -> IO a -- | a class for types that can be parsed from exactly one command line -- argument class Arguable a parse :: Arguable a => String -> Maybe a name :: Arguable a => a -> String -- | a class for types that can be parsed from some number of command line -- arguments class Argument a parseArg :: Argument a => [String] -> [(a, [String])] argName :: Argument a => a -> String -- | a wrapper type to indicate a non-greedy list or maybe newtype NonGreedy m a NonGreedy :: m a -> NonGreedy m a unNonGreedy :: NonGreedy m a -> m a -- | a class for tuples of types that can be parsed from the entire list of -- arguments class ArgumentTuple a parseArgsFrom :: ArgumentTuple a => [String] -> Maybe a usageFor :: ArgumentTuple a => a -> String -- | use :& to construct arbitrary length tuples of any parsable -- arguments data (:&) a b (:&) :: a -> b -> :& a b instance [overlap ok] Show (m a) => Show (NonGreedy m a) instance [overlap ok] Eq (m a) => Eq (NonGreedy m a) instance [overlap ok] (Show a, Show b) => Show (a :& b) instance [overlap ok] (Eq a, Eq b) => Eq (a :& b) instance [overlap ok] (Argument o, Argument n, Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (o, n, m, l, k, j, i, h, g, f, e, d, c, b, a) instance [overlap ok] (Argument n, Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (n, m, l, k, j, i, h, g, f, e, d, c, b, a) instance [overlap ok] (Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (m, l, k, j, i, h, g, f, e, d, c, b, a) instance [overlap ok] (Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (l, k, j, i, h, g, f, e, d, c, b, a) instance [overlap ok] (Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (k, j, i, h, g, f, e, d, c, b, a) instance [overlap ok] (Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (j, i, h, g, f, e, d, c, b, a) instance [overlap ok] (Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (i, h, g, f, e, d, c, b, a) instance [overlap ok] (Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (h, g, f, e, d, c, b, a) instance [overlap ok] (Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (g, f, e, d, c, b, a) instance [overlap ok] (Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (f, e, d, c, b, a) instance [overlap ok] (Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (e, d, c, b, a) instance [overlap ok] (Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (d, c, b, a) instance [overlap ok] (Argument c, Argument b, Argument a) => ArgumentTuple (c, b, a) instance [overlap ok] (Argument b, Argument a) => ArgumentTuple (b, a) instance [overlap ok] Argument a => ArgumentTuple a instance [overlap ok] (Argument a, ArgumentTuple y) => ArgumentTuple (a :& y) instance [overlap ok] ArgumentTuple () instance [overlap ok] Argument String instance [overlap ok] Argument (m a) => Argument (NonGreedy m a) instance [overlap ok] Arguable a => Argument [a] instance [overlap ok] Arguable a => Argument (Maybe a) instance [overlap ok] Arguable a => Argument a instance [overlap ok] Arguable Char instance [overlap ok] Arguable FilePath instance [overlap ok] Arguable Text instance [overlap ok] Arguable String instance [overlap ok] (Typeable t, Read t) => Arguable t