shelly-extra 0.2.2.1 → 0.2.3
raw patch · 3 files changed
+20/−19 lines, 3 filesdep ~shelly
Dependency ranges changed: shelly
Files
- Shelly/Background.hs +7/−7
- shelly-extra.cabal +8/−7
- test/main.hs +5/−5
Shelly/Background.hs view
@@ -18,9 +18,9 @@ import qualified Control.Concurrent.MSem as Sem -- | Create a 'BgJobManager' that has a 'limit' on the max number of background tasks.--- an invocation of jobs is independent of any others, and not tied to the ShIO monad in any way.+-- an invocation of jobs is independent of any others, and not tied to the Sh monad in any way. -- This blocks the execution of the program until all 'background' jobs are finished.-jobs :: Int -> (BgJobManager -> ShIO a) -> ShIO a+jobs :: Int -> (BgJobManager -> Sh a) -> Sh a jobs limit action = do unless (limit > 0) $ terror "expected limit to be > 0" availableJobsSem <- liftIO $ Sem.new limit@@ -40,14 +40,14 @@ -- | Returns the promised result from a backgrounded task. Blocks until -- the task completes.-getBgResult :: BgResult a -> ShIO a+getBgResult :: BgResult a -> Sh a getBgResult (BgResult mvar) = liftIO $ takeMVar mvar --- | Run the `ShIO` task asynchronously in the background, returns+-- | Run the `Sh` task asynchronously in the background, returns -- the `BgResult a`, a promise immediately. Run "getBgResult" to wait for the result.--- The background task will inherit the current ShIO context--- The 'BjJobManager' ensures the max jobs limit must be sufficient for the parent and all children.-background :: BgJobManager -> ShIO a -> ShIO (BgResult a)+-- The background task will inherit the current Sh context+-- The 'BgJobManager' ensures the max jobs limit must be sufficient for the parent and all children.+background :: BgJobManager -> Sh a -> Sh (BgResult a) background (BgJobManager manager) proc = do state <- get liftIO $ do
shelly-extra.cabal view
@@ -1,17 +1,18 @@ Name: shelly-extra -Version: 0.2.2.1+Version: 0.2.3 Synopsis: shelly features that require extra dependencies -Description: Please see the shelly package. Shelly provides a single module for convenient- systems programming in Haskell, similar in spirit to POSIX shells.+Description: A background job implementation for performing tasks in parallel. .- shelly-extra is designed to be a grab bag for functionality that+ Please see the shelly package. Shelly provides a single module for convenient systems programming in Haskell, similar in spirit to POSIX shells.+ .+ shelly-extra is designed to be a grab bag for functionality that either+ . * requires extra dependencies .- * or is application specific and not generally applicable+ * is application specific and not generally applicable .- currently contains a background job implementation for performing tasks in parallel Homepage: https://github.com/yesodweb/Shelly.hs@@ -27,7 +28,7 @@ Library Exposed-modules: Shelly.Background - Build-depends: base >= 4 && < 5, shelly >= 0.10, SafeSemaphore+ Build-depends: base >= 4 && < 5, shelly >= 0.13, SafeSemaphore ghc-options: -Wall
test/main.hs view
@@ -5,11 +5,11 @@ import Shelly import Shelly.Background-import Data.Text.Lazy (Text, stripEnd)+import Data.Text (Text, stripEnd) import Test.HUnit default (Text) -shIOUnit :: ShIO ()+shIOUnit :: Sh () shIOUnit = do cmd "pwd" chdir ".." $@@ -32,11 +32,11 @@ echo recho (res :: Text) <- cmd "pwd"- liftIO $ putStrLn $ show res+ liftIO $ print res inspect res - inspect =<< (cmd "echo" "compose" :: ShIO Text)- inspect =<< (cmd "pwd")+ inspect =<< (cmd "echo" "compose" :: Sh Text)+ inspect =<< cmd "pwd" -- this somehow forces more evaluation shIOUnit