turtle 1.0.0 → 1.0.1
raw patch · 4 files changed
+77/−7 lines, 4 files
Files
- src/Turtle/Pattern.hs +1/−1
- src/Turtle/Prelude.hs +1/−1
- src/Turtle/Tutorial.hs +68/−3
- turtle.cabal +7/−2
src/Turtle/Pattern.hs view
@@ -27,7 +27,7 @@ Use @do@ notation to structure more complex patterns: >>> :{-let bit = ("0" *> pure False) <|> ("1" *> pure True);+let bit = ("0" *> pure False) <|> ("1" *> pure True) :: Pattern Bool; portableBitMap = do { "P1" ; width <- spaces1 *> decimal
src/Turtle/Prelude.hs view
@@ -527,7 +527,7 @@ exit n = exitWith (ExitFailure n) -- | Throw an exception using the provided `Text` message-die :: Text -> IO ()+die :: Text -> IO a die txt = throwIO (userError (unpack txt)) {-| Create a temporary directory underneath the given directory
src/Turtle/Tutorial.hs view
@@ -64,6 +64,9 @@ -- * Loops -- $loops + -- * External commands+ -- $external+ -- * Folds -- $folds @@ -156,7 +159,7 @@ -- -- Second, the Haskell `echo` explicitly quotes its string argument whereas the -- Bash @echo@ does not. In Bash every token is a string by default and you--- distinguish variables by prepending a dollar sign to them. In Haskell the+-- distinguish variables by prepending a dollar sign to them. In Haskell -- the situation is reversed: every token is a variable by default and you -- distinguish strings by quoting them. The following example highlights the -- difference:@@ -707,9 +710,21 @@ -- > $ ./example.hs -- > example.hs: user error (false failed with exit code: 1) --+-- You should also check out the `proc` command, which is less powerful but+-- safer since it decreases the likelihood of code injection or malformed+-- commands:+--+-- @+-- `proc`+-- :: Text -- Program+-- :: [Text] -- Arguments+-- -> Shell Text -- Standard input (as lines of \`Text\`)+-- -> IO ExitCode -- Exit code of the shell command+-- @+-- -- Most of the commands in this library do not actually invoke an external--- shell. Instead, they indirectly wrap other Haskell libraries that bind to C--- code.+-- shell or program. Instead, they indirectly wrap other Haskell libraries that+-- bind to C code. -- $format --@@ -984,6 +999,56 @@ -- > FilePath "/tmp/orbit-gabriel" -- > FilePath "/tmp/ssh-vREYGbWGpiCa" -- > FilePath "/tmp/.ICE-unix"++-- $external+--+-- You can embed external shell commands as streams within your Haskell program.+--+-- For example, suppose that we want to use the system's built in @ls@ command.+-- We can just run:+--+-- > Prelude Turtle> stdout (inshell "ls" empty)+-- > .X11-unix+-- > .X0-lock+-- > pulse-PKdhtXMmr18n+-- > pulse-xHYcZ3zmN3Fv+-- > tracker-gabriel+-- > pulse-PYi1hSlWgNj2+-- > orbit-gabriel+-- > ssh-vREYGbWGpiCa+-- > .ICE-unix+--+-- This works because type of `inshell` is:+--+-- @+-- `inshell`+-- :: Text -- Command line+-- -> Shell Text -- Standard input to feed to program+-- -> Shell Text -- Standard output produced by program+-- @+--+-- This means you can use `inshell` to embed arbitrary external utilities as+-- first class streams within your Haskell program:+--+-- > Turtle Prelude> stdout (inshell "awk '{ print $1 }'" "123 456")+-- > 123+--+-- You should also check out the `inproc` command, which is less powerful but+-- safer since it decreases the likelihood of code injection or malformed+-- commands:+--+-- @+-- `inproc`+-- :: Text -- Program+-- -> [Text] -- Arguments+-- -> Shell Text -- Standard input to feed to program+-- -> Shell Text -- Standard output produced by program+-- @+--+-- Using `inproc`, you would write:+--+-- > Turtle Prelude> stdout (inproc "awk" ["{ print $1 }"] "123 456")+-- > 123 -- $folds --
turtle.cabal view
@@ -1,5 +1,5 @@ Name: turtle-Version: 1.0.0+Version: 1.0.1 Cabal-Version: >=1.10 Build-Type: Simple License: BSD3@@ -11,7 +11,7 @@ Synopsis: Shell programming, Haskell-style Description: @turtle@ is a reimplementation of the Unix command line environment in Haskell so that you can use Haskell as both a shell and a scripting- language+ language. . Features include: .@@ -33,6 +33,11 @@ . Read "Turtle.Tutorial" for a detailed tutorial or "Turtle.Prelude" for a quick-start guide+ .+ @turtle@ is designed to be beginner-friendly, but as a result lacks certain+ features, like tracing commands. If you feel comfortable using @turtle@+ then you should also check out the @Shelly@ library which provides similar+ functionality. Category: System Source-Repository head Type: git