packages feed

commander-cli 0.2.0.0 → 0.2.0.1

raw patch · 4 files changed

+26/−30 lines, 4 filesdep ~base

Dependency ranges changed: base

Files

README.md view
@@ -1,6 +1,8 @@-# Commander+# commander-cli -The commander package contains two DSLs for describing command line programs, +[![Build Status](https://travis-ci.org/SamuelSchlesinger/commander-cli.svg?branch=master)](https://travis-ci.org/SamuelSchlesinger/commander-cli)++The commander-cli package contains two DSLs for describing command line programs,  one at the type level and one at the term level. The one at the type level looks  like this: 
app/Main.hs view
@@ -7,7 +7,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-}-{-# LANGUAGE BlockArguments #-} module Main where  import Control.Monad@@ -42,10 +41,10 @@   <+> sub @"tasks" listTasks   <+> sub @"priorities" listPriorities -editTask = arg @"task-name" \taskName -> raw -  $ withTask taskName \Context{home} task -> callProcess "vim" [home ++ "/tasks/" ++ taskName ++ ".task"]+editTask = arg @"task-name" $ \taskName -> raw +  $ withTask taskName $ \Context{home} task -> callProcess "vim" [home ++ "/tasks/" ++ taskName ++ ".task"] -newTask = arg @"task-name" \taskName -> raw do+newTask = arg @"task-name" $ \taskName -> raw $ do   Context{home, tasks} <- initializeOrFetch   if not (taskName `elem` tasks)     then do@@ -55,8 +54,8 @@       callProcess "vim" [path]     else putStrLn $ "task " ++ taskName ++ " already exists." -closeTask = arg @"task-name" \taskName -> raw -  $ withTask taskName \Context{home, tasks} mtask ->+closeTask = arg @"task-name" $ \taskName -> raw +  $ withTask taskName $ \Context{home, tasks} mtask ->     case mtask of       Just Task{priorities} ->         if priorities == [] @@ -64,13 +63,13 @@           else putStrLn $ "task " ++ taskName ++ " has remaining priorities."       Nothing -> putStrLn "task is corrupted" -listTasks = raw do+listTasks = raw $ do   Context{tasks} <- initializeOrFetch   mapM_ putStrLn tasks -listPriorities = raw do+listPriorities = raw $ do   Context{tasks} <- initializeOrFetch-  forM_ tasks $ \taskName -> withTask taskName \_ mtask -> +  forM_ tasks $ \taskName -> withTask taskName $ \_ mtask ->      case mtask of       Just Task{name, priorities} -> do         putStrLn $ name ++ ": "
commander-cli.cabal view
@@ -1,7 +1,7 @@ cabal-version:       2.4  name:                commander-cli-version:             0.2.0.0+version:             0.2.0.1 synopsis:            A command line argument/option parser library built around a monadic metaphor description:         A command line argument/option parser library built around a monadic metaphor. homepage:            https://github.com/SamuelSchlesinger/commander-cli@@ -17,7 +17,6 @@ library   exposed-modules:     Options.Commander   other-extensions:    ViewPatterns,-                       DerivingVia,                        StandaloneDeriving,                        GeneralizedNewtypeDeriving,                        DerivingStrategies,@@ -29,14 +28,13 @@                        RecordWildCards,                        TypeApplications,                        RankNTypes,-                       BlockArguments,                        DeriveFunctor,                        AllowAmbiguousTypes,                        PolyKinds,                        GADTs,                        TypeOperators,                        DataKinds-  build-depends:       base >=4.13 && < 5,+  build-depends:       base >=4.12 && < 5,                        mtl >=2.2 && <2.3,                        text >=1.2 && < 1.3,                        unordered-containers >=0.2 && < 0.3@@ -53,10 +51,8 @@                        LambdaCase,                        DataKinds,                        TypeApplications,-                       TypeOperators,-                       BlockArguments-  build-depends:-                       base >=4.13 && < 5,+                       TypeOperators+  build-depends:       base >=4.12 && < 5,                        mtl >=2.2,                        text >=1.2.4 && < 1.3,                        directory >= 1.3 && < 1.4,@@ -68,7 +64,7 @@ test-suite test-commander   type:                exitcode-stdio-1.0   main-is:             Test.hs-  build-depends:       base >= 4.13 && < 5,+  build-depends:       base >= 4.12 && < 5,                        text >=1.2.4 && < 1.3,                        unordered-containers >= 0.2 && < 0.3,                        commander-cli
src/Options/Commander.hs view
@@ -11,7 +11,6 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE RankNTypes #-}-{-# LANGUAGE BlockArguments #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE PolyKinds #-}@@ -225,12 +224,12 @@   pure = Victory  instance MonadTrans (CommanderT state) where-  lift ma = Action \state -> do+  lift ma = Action $ \state -> do     a <- ma     return (pure a, state)  instance MonadIO m => MonadIO (CommanderT state m) where-  liftIO ma = Action \state -> do+  liftIO ma = Action $ \state -> do     a <- liftIO ma     return (pure a, state) @@ -246,7 +245,7 @@ --   Case 2: Victory a >>= return  --         = Victory a --   Case 3: Action action >>= return---         = Action \state -> do+--         = Action $ \state -> do --             (action', state') <- action state --             return (action' >>= return, state') --@@ -261,10 +260,10 @@ --          = k a >>= f --          = (Victory a >>= k) >>= f --    Case 3: Action action >>= (\x -> k x >>= h)---          = Action \state -> do+--          = Action $ \state -> do --              (action', state') <- action state --              return (action' >>= (\x -> k x >>= h), state')---          = Action \state -> do+--          = Action $ \state -> do --              (action', state') <- action state --              return ((action' >>= k) >>= h, state') -- by IH --    On the other hand,@@ -272,7 +271,7 @@ --          = Action (\state -> do --              (action', state') <- action state --              return (action' >>= k, state') >>= h---          = Action \state -> do+--          = Action $ \state -> do --              (action', state') <- action state --              return ((action' >>= k) >>= h, state') --               @@ -300,7 +299,7 @@ instance Monad m => Monad (CommanderT state m) where   Defeat >>= _ = Defeat   Victory a >>= f = f a-  Action action >>= f = Action \state -> do+  Action action >>= f = Action $ \state -> do     (action', state') <- action state     return (action' >>= f, state') @@ -308,7 +307,7 @@   empty = Defeat    Defeat <|> a = a    v@(Victory _) <|> _ = v-  Action action <|> p = Action \state -> do+  Action action <|> p = Action $ \state -> do     (action', state') <- action state      return (action' <|> p, state') @@ -366,7 +365,7 @@  instance HasProgram p => HasProgram (Usage p) where   data ProgramT (Usage p) m a = UsageProgramT-  run _ = Action \s -> do+  run _ = Action $ \s -> do     liftIO $ do       putStrLn "usage:"       void . traverse (putStrLn . unpack) $ invocations @p