packages feed

multiarg 0.24.0.4 → 0.26.0.0

raw patch · 4 files changed

+69/−39 lines, 4 filesdep +bifunctors

Dependencies added: bifunctors

Files

current-versions.txt view
@@ -1,7 +1,7 @@ This package was tested to work with these dependency versions and compiler version. These are the default versions fetched by cabal install.-Tested as of: 2014-02-24 12:12:58.625909 UTC+Tested as of: 2014-03-01 20:12:15.212998 UTC Path to compiler: ghc-7.6.3 Compiler description: 7.6.3 @@ -32,6 +32,20 @@     time-1.4.0.1     unix-2.6.0.1 -/home/massysett/multiarg/sunlight-8428/db:-    multiarg-0.24.0.4+/home/massysett/multiarg/sunlight-29118/db:+    bifunctors-4.1.1+    comonad-4.0+    contravariant-0.4.4+    distributive-0.4+    hashable-1.2.1.0+    mtl-2.1.2+    multiarg-0.26.0.0+    nats-0.1.2+    semigroupoids-4.0+    semigroups-0.12.2+    tagged-0.7+    text-1.1.0.0+    transformers-0.3.0.0+    transformers-compat-0.1.1.1+    unordered-containers-0.2.3.3 
lib/System/Console/MultiArg/CommandLine.hs view
@@ -22,7 +22,6 @@   -- * Types   , ProgName   , Opts(..)-  , MapShortcuts(..)   , OptsWithPosArgs(..)   , Mode(..) @@ -50,6 +49,7 @@ import qualified System.IO as IO import Control.Applicative ( many, (<|>), optional,                              (<$), (<*>), (<*), (<$>))+import Data.Bifunctor import Data.List (find) import Data.Maybe (catMaybes, fromJust) import qualified Data.Set as Set@@ -77,11 +77,7 @@  -- | Specifies a set of options. data Opts s a = Opts-  { oOptions :: [C.OptSpec a]-  -- ^ If the user does not specify any shortcut options, she may-  -- specify any number of these options.--  , oShortcuts :: [C.OptSpec s]+  { oShortcuts :: [C.OptSpec s]   -- ^ Shortcut options are commonly options such as @--help@ or   -- @--version@. Such options must be specified alone on the command   -- line.  The parser looks for one of these options first.  If it@@ -91,15 +87,28 @@   -- option is found, the parser processes non-shortcut options   -- instead. +  , oOptions :: [C.OptSpec a]+  -- ^ If the user does not specify any shortcut options, she may+  -- specify any number of these options.+   } +instance Bifunctor Opts where+  bimap fa fc o = Opts+    { oShortcuts = map (fmap fa) . oShortcuts $ o+    , oOptions = map (fmap fc) . oOptions $ o+    }++instance Functor (Opts a) where+  fmap f o = o { oOptions = fmap (fmap f) . oOptions $ o }+ -- | Creates an Opts with a help shortcut option. optsHelp   :: h   -- ^ Whatever type you wish to use for help   -> [C.OptSpec a]   -> Opts h a-optsHelp h os = Opts os [C.OptSpec ["help"] "h" (C.NoArg h)]+optsHelp h = Opts [C.OptSpec ["help"] "h" (C.NoArg h)]  -- | Creates an Opts with help and version shortcut options. optsHelpVersion@@ -111,18 +120,8 @@    -> [C.OptSpec a]   -> Opts h a-optsHelpVersion h v os = Opts os [ C.OptSpec ["help"] "h" (C.NoArg h)-                                 , C.OptSpec ["version"] "v" (C.NoArg v) ]--instance Functor (Opts s) where-  fmap f (Opts os ss) = Opts (map (fmap f) os) ss---- | Things that contain shortcut options that can be changed.-class MapShortcuts f where-  smap :: (a -> b) -> f a o -> f b o--instance MapShortcuts Opts where-  smap f (Opts os ss) = Opts os (map (fmap f) ss)+optsHelpVersion h v = Opts [ C.OptSpec ["help"] "h" (C.NoArg h)+                            , C.OptSpec ["version"] "v" (C.NoArg v) ]  -- | Specification for both options and positional arguments. data OptsWithPosArgs s a = OptsWithPosArgs@@ -131,12 +130,18 @@   , opPosArg :: String -> Either C.InputError a   } -instance MapShortcuts OptsWithPosArgs where-  smap f (OptsWithPosArgs os i p) = OptsWithPosArgs (smap f os) i p+instance Bifunctor OptsWithPosArgs where+  bimap fa fc o = OptsWithPosArgs+    { opOpts = bimap fa fc . opOpts $ o+    , opIntersperse = opIntersperse o+    , opPosArg = fmap (fmap fc) . opPosArg $ o+    }  instance Functor (OptsWithPosArgs s) where-  fmap f (OptsWithPosArgs os i p) =-    OptsWithPosArgs (fmap f os) i (fmap (fmap f) p)+  fmap f o = o+    { opOpts = fmap f . opOpts $ o+    , opPosArg = fmap (fmap f) . opPosArg $ o+    }  -- | Specifies a mode. data Mode s r = forall a. Mode@@ -158,6 +163,16 @@   -- that is specific to this mode.   } +instance Bifunctor Mode where+  bimap fa fc (Mode n r o) = Mode+    { mModeName = n+    , mGetResult = fmap fc r+    , mOpts = first fa o+    }++instance Functor (Mode s) where+  fmap f (Mode n gr os) = Mode n (fmap f gr) os+ -- | Creates a Mode with a help option (help specific to the mode.) modeHelp   :: String@@ -184,16 +199,10 @@   -> Mode h r  modeHelp n h getR os i p =-  Mode n getR (OptsWithPosArgs (Opts os ss) i p)+  Mode n getR (OptsWithPosArgs (Opts ss os) i p)   where     ss = [C.OptSpec ["help"] "h" (C.NoArg h)] -instance MapShortcuts Mode where-  smap f (Mode n g o) = Mode n g (smap f o)--instance Functor (Mode s) where-  fmap f (Mode n gr os) = Mode n (fmap f gr) os- parseOpts :: Opts s a -> P.Parser (Either s [a]) parseOpts os = do   let specials = oShortcuts os@@ -406,7 +415,7 @@   -- arguments are returned here. simpleHelp getHelp os ir getArg = do   let shortcuts = [C.OptSpec ["help"] "h" (C.NoArg (displayAct getHelp))]-      opts = OptsWithPosArgs (Opts os shortcuts) ir getArg+      opts = OptsWithPosArgs (Opts shortcuts os) ir getArg   ei <- simpleIOCustomError errorActDisplayHelp opts   case ei of     Left act -> act@@ -445,7 +454,7 @@                       (C.NoArg (displayAct getHelp))                   , C.OptSpec ["version"] ""                       (C.NoArg (displayAct getVer)) ]-      opts = OptsWithPosArgs (Opts os shortcuts) ir getArg+      opts = OptsWithPosArgs (Opts shortcuts os) ir getArg   ei <- simpleIOCustomError errorActDisplayHelp opts   case ei of     Left act -> act
minimum-versions.txt view
@@ -1,7 +1,7 @@ This package was tested to work with these dependency versions and compiler version. These are the minimum versions given in the .cabal file.-Tested as of: 2014-02-24 12:12:58.625909 UTC+Tested as of: 2014-03-01 20:12:15.212998 UTC Path to compiler: ghc-7.4.1 Compiler description: 7.4.1 @@ -33,6 +33,12 @@     time-1.4     unix-2.5.1.0 -/home/massysett/multiarg/sunlight-8428/db:-    multiarg-0.24.0.4+/home/massysett/multiarg/sunlight-29118/db:+    bifunctors-0.1.3.1+    comonad-1.1.1.6+    contravariant-0.2.0.2+    multiarg-0.26.0.0+    semigroupoids-1.3.4+    semigroups-0.8.5+    transformers-0.3.0.0 
multiarg.cabal view
@@ -1,5 +1,5 @@ Name: multiarg-Version: 0.24.0.4+Version: 0.26.0.0 Cabal-version: >=1.8 Build-Type: Simple License: BSD3@@ -40,6 +40,7 @@ Library   Build-depends:       base >=4.5.0.0 && < 5+    , bifunctors >= 0.1.3.1     , containers >=0.4.2.1    hs-source-dirs: lib