Hello community, here is the log from the commit of package ghc-turtle for openSUSE:Factory checked in at 2020-05-11 13:36:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-turtle (Old) and /work/SRC/openSUSE:Factory/.ghc-turtle.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-turtle" Mon May 11 13:36:35 2020 rev:11 rq:801059 version:1.5.19 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-turtle/ghc-turtle.changes 2020-03-09 14:17:09.454655860 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-turtle.new.2738/ghc-turtle.changes 2020-05-11 13:36:39.264526515 +0200 @@ -1,0 +2,18 @@ +Wed May 6 06:52:11 UTC 2020 - [email protected] + +- Update turtle to version 1.5.19. + 1.5.19 + + * Add pattern synonyms for `Size` + + 1.5.18 + + * Fix space leak + + 1.5.17 + + * Add `optionsExt`: Extended version of `options` with header, footer, + porgram-description and version information in `--help` flag + * Add `readlink` + +------------------------------------------------------------------- Old: ---- turtle-1.5.16.tar.gz New: ---- turtle-1.5.19.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-turtle.spec ++++++ --- /var/tmp/diff_new_pack.AF7bpF/_old 2020-05-11 13:36:40.076528216 +0200 +++ /var/tmp/diff_new_pack.AF7bpF/_new 2020-05-11 13:36:40.080528225 +0200 @@ -19,7 +19,7 @@ %global pkg_name turtle %bcond_with tests Name: ghc-%{pkg_name} -Version: 1.5.16 +Version: 1.5.19 Release: 0 Summary: Shell programming, Haskell-style License: BSD-3-Clause ++++++ turtle-1.5.16.tar.gz -> turtle-1.5.19.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/turtle-1.5.16/CHANGELOG.md new/turtle-1.5.19/CHANGELOG.md --- old/turtle-1.5.16/CHANGELOG.md 2020-01-20 18:52:57.000000000 +0100 +++ new/turtle-1.5.19/CHANGELOG.md 2001-09-09 03:46:40.000000000 +0200 @@ -1,3 +1,17 @@ +1.5.19 + +* Add pattern synonyms for `Size` + +1.5.18 + +* Fix space leak + +1.5.17 + +* Add `optionsExt`: Extended version of `options` with header, footer, + porgram-description and version information in `--help` flag +* Add `readlink` + 1.5.16 * Add `cptreeL` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/turtle-1.5.16/src/Turtle/Options.hs new/turtle-1.5.19/src/Turtle/Options.hs --- old/turtle-1.5.16/src/Turtle/Options.hs 2020-01-20 18:52:57.000000000 +0100 +++ new/turtle-1.5.19/src/Turtle/Options.hs 2001-09-09 03:46:40.000000000 +0200 @@ -71,6 +71,7 @@ , subcommand , subcommandGroup , options + , optionsExt ) where @@ -107,6 +108,30 @@ prefs = Opts.showHelpOnError #endif +{-| Parse the given options from the command line and add additional information + + Extended version of @options@ with program version header and footer information +-} +optionsExt :: MonadIO io => Header -> Footer -> Description -> Version -> Parser a -> io a +optionsExt header footer desc version parser = liftIO + $ Opts.customExecParser (Opts.prefs prefs) + $ Opts.info (Opts.helper <*> versionOption <*> parser) + (Opts.headerDoc (Just (getHeader header)) <> + Opts.footerDoc (Just (getFooter footer)) <> + Opts.progDescDoc (Just (getDescription desc))) + where + versionOption = + Opts.infoOption + (Text.unpack version) + (Opts.long "version" <> Opts.help "Show version") + prefs :: Opts.PrefsMod +#if MIN_VERSION_optparse_applicative(0,13,0) + prefs = Opts.showHelpOnError <> Opts.showHelpOnEmpty +#else + prefs = Opts.showHelpOnError +#endif + + {-| The name of a command-line argument This is used to infer the long name and metavariable for the command line @@ -135,6 +160,21 @@ newtype Description = Description { getDescription :: Doc } deriving (IsString) +{-| Header of the program + + This description will appear in the header of the @--help@ output +-} +newtype Header = Header { getHeader :: Doc } + deriving (IsString) +{-| Footer of the program + + This description will appear in the footer of the @--help@ output +-} +newtype Footer = Fotter { getFooter :: Doc } + deriving (IsString) + +-- | Program Version +type Version = Text {-| A helpful message explaining what a flag does This will appear in the @--help@ output diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/turtle-1.5.16/src/Turtle/Prelude.hs new/turtle-1.5.19/src/Turtle/Prelude.hs --- old/turtle-1.5.16/src/Turtle/Prelude.hs 2020-01-20 18:52:57.000000000 +0100 +++ new/turtle-1.5.19/src/Turtle/Prelude.hs 2001-09-09 03:46:40.000000000 +0200 @@ -4,6 +4,8 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TupleSections #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE ViewPatterns #-} -- | This module provides a large suite of utilities that resemble Unix -- utilities. @@ -121,6 +123,7 @@ , cd , pwd , home + , readlink , realpath , mv , mkdir @@ -250,7 +253,7 @@ -- * File size , du - , Size + , Size(B, KB, MB, GB, TB, KiB, MiB, GiB, TiB) , sz , bytes , kilobytes @@ -943,6 +946,14 @@ home :: MonadIO io => io FilePath home = liftIO Filesystem.getHomeDirectory +-- | Get the path pointed to by a symlink +readlink :: MonadIO io => FilePath -> io FilePath +readlink = + fmap Filesystem.decodeString + . liftIO + . System.Directory.getSymbolicLinkTarget + . Filesystem.encodeString + -- | Canonicalize a path realpath :: MonadIO io => FilePath -> io FilePath realpath path = liftIO (Filesystem.canonicalizePath path) @@ -1609,7 +1620,7 @@ cat = msum grepWith :: (b -> Text) -> Pattern a -> Shell b -> Shell b -grepWith f pattern = mfilter (not . null . match pattern . f) +grepWith f pattern' = mfilter (not . null . match pattern' . f) -- | Keep all lines that match the given `Pattern` grep :: Pattern a -> Shell Line -> Shell Line @@ -1632,12 +1643,12 @@ necessarily incomplete. -} sed :: Pattern Text -> Shell Line -> Shell Line -sed pattern s = do - when (matchesEmpty pattern) (die message) - let pattern' = fmap Text.concat - (many (pattern <|> fmap Text.singleton anyChar)) +sed pattern' s = do + when (matchesEmpty pattern') (die message) + let pattern'' = fmap Text.concat + (many (pattern' <|> fmap Text.singleton anyChar)) line <- s - txt':_ <- return (match pattern' (lineToText line)) + txt':_ <- return (match pattern'' (lineToText line)) select (textToLines txt') where message = "sed: the given pattern matches the empty string" @@ -1647,23 +1658,23 @@ line -} sedPrefix :: Pattern Text -> Shell Line -> Shell Line -sedPrefix pattern s = do +sedPrefix pattern' s = do line <- s - txt':_ <- return (match ((pattern <> chars) <|> chars) (lineToText line)) + txt':_ <- return (match ((pattern' <> chars) <|> chars) (lineToText line)) select (textToLines txt') -- | Like `sed`, but the provided substitution must match the end of the line sedSuffix :: Pattern Text -> Shell Line -> Shell Line -sedSuffix pattern s = do +sedSuffix pattern' s = do line <- s - txt':_ <- return (match ((chars <> pattern) <|> chars) (lineToText line)) + txt':_ <- return (match ((chars <> pattern') <|> chars) (lineToText line)) select (textToLines txt') -- | Like `sed`, but the provided substitution must match the entire line sedEntire :: Pattern Text -> Shell Line -> Shell Line -sedEntire pattern s = do +sedEntire pattern' s = do line <- s - txt':_ <- return (match (pattern <|> chars)(lineToText line)) + txt':_ <- return (match (pattern' <|> chars)(lineToText line)) select (textToLines txt') -- | Make a `Shell Text -> Shell Text` function work on `FilePath`s instead. @@ -1697,20 +1708,20 @@ -> Pattern Text -> FilePath -> io () -inplaceWith sed_ pattern file = liftIO (runManaged (do +inplaceWith sed_ pattern' file = liftIO (runManaged (do here <- pwd (tmpfile, handle) <- mktemp here "turtle" - outhandle handle (sed_ pattern (input file)) + outhandle handle (sed_ pattern' (input file)) liftIO (hClose handle) copymod file tmpfile mv tmpfile file )) -- | Search a directory recursively for all files matching the given `Pattern` find :: Pattern a -> FilePath -> Shell FilePath -find pattern dir = do +find pattern' dir = do path <- lsif isNotSymlink dir Right txt <- return (Filesystem.toText path) - _:_ <- return (match pattern txt) + _:_ <- return (match pattern' txt) return path where isNotSymlink :: FilePath -> IO Bool @@ -1907,7 +1918,7 @@ -- | Split a line into chunks delimited by the given `Pattern` cut :: Pattern a -> Text -> [Text] -cut pattern txt = head (match (selfless chars `sepBy` pattern) txt) +cut pattern' txt = head (match (selfless chars `sepBy` pattern') txt) -- This `head` should be safe ... in theory -- | Get the current time @@ -1973,41 +1984,147 @@ then format (d%"."%d%" GB") remainingGigabytes remainingMegabytes else format (d%"."%d%" TB") numTerabytes remainingGigabytes ) +{-| Construct a 'Size' from an integer in bytes + +>>> format sz (B 42) +"42 B" +-} +pattern B :: Integral n => n -> Size +pattern B { bytes } <- (fromInteger . _bytes -> bytes) + where + B = fromIntegral +{-# COMPLETE B #-} + +{-| Construct a 'Size' from an integer in kilobytes + +>>> format sz (KB 42) +"42.0 KB" +>>> let B n = KB 1 in n +1000 +-} +pattern KB :: Integral n => n -> Size +pattern KB { kilobytes } <- (\(B x) -> x `div` 1000 -> kilobytes) + where + KB = B . (* 1000) +{-# COMPLETE KB #-} + +{-| Construct a 'Size' from an integer in megabytes + +>>> format sz (MB 42) +"42.0 MB" +>>> let KB n = MB 1 in n +1000 +-} +pattern MB :: Integral n => n -> Size +pattern MB { megabytes } <- (\(KB x) -> x `div` 1000 -> megabytes) + where + MB = KB . (* 1000) +{-# COMPLETE MB #-} + +{-| Construct a 'Size' from an integer in gigabytes + +>>> format sz (GB 42) +"42.0 GB" +>>> let MB n = GB 1 in n +1000 +-} +pattern GB :: Integral n => n -> Size +pattern GB { gigabytes } <- (\(MB x) -> x `div` 1000 -> gigabytes) + where + GB = MB . (* 1000) +{-# COMPLETE GB #-} + +{-| Construct a 'Size' from an integer in terabytes + +>>> format sz (TB 42) +"42.0 TB" +>>> let GB n = TB 1 in n +1000 +-} +pattern TB :: Integral n => n -> Size +pattern TB { terabytes } <- (\(GB x) -> x `div` 1000 -> terabytes) + where + TB = GB . (* 1000) +{-# COMPLETE TB #-} + +{-| Construct a 'Size' from an integer in kibibytes + +>>> format sz (KiB 42) +"43.8 KB" +>>> let B n = KiB 1 in n +1024 +-} +pattern KiB :: Integral n => n -> Size +pattern KiB { kibibytes } <- (\(B x) -> x `div` 1024 -> kibibytes) + where + KiB = B . (* 1024) +{-# COMPLETE KiB #-} + +{-| Construct a 'Size' from an integer in mebibytes + +>>> format sz (MiB 42) +"44.40 MB" +>>> let KiB n = MiB 1 in n +1024 +-} +pattern MiB :: Integral n => n -> Size +pattern MiB { mebibytes } <- (\(KiB x) -> x `div` 1024 -> mebibytes) + where + MiB = KiB . (* 1024) +{-# COMPLETE MiB #-} + +{-| Construct a 'Size' from an integer in gibibytes + +>>> format sz (GiB 42) +"45.97 GB" +>>> let MiB n = GiB 1 in n +1024 +-} +pattern GiB :: Integral n => n -> Size +pattern GiB { gibibytes } <- (\(MiB x) -> x `div` 1024 -> gibibytes) + where + GiB = MiB . (* 1024) +{-# COMPLETE GiB #-} + +{-| Construct a 'Size' from an integer in tebibytes + +>>> format sz (TiB 42) +"46.179 TB" +>>> let GiB n = TiB 1 in n +1024 +-} +pattern TiB :: Integral n => n -> Size +pattern TiB { tebibytes } <- (\(GiB x) -> x `div` 1024 -> tebibytes) + where + TiB = GiB . (* 1024) +{-# COMPLETE TiB #-} + -- | Extract a size in bytes bytes :: Integral n => Size -> n -bytes = fromInteger . _bytes -- | @1 kilobyte = 1000 bytes@ kilobytes :: Integral n => Size -> n -kilobytes = (`div` 1000) . bytes -- | @1 megabyte = 1000 kilobytes@ megabytes :: Integral n => Size -> n -megabytes = (`div` 1000) . kilobytes -- | @1 gigabyte = 1000 megabytes@ gigabytes :: Integral n => Size -> n -gigabytes = (`div` 1000) . megabytes -- | @1 terabyte = 1000 gigabytes@ terabytes :: Integral n => Size -> n -terabytes = (`div` 1000) . gigabytes -- | @1 kibibyte = 1024 bytes@ kibibytes :: Integral n => Size -> n -kibibytes = (`div` 1024) . bytes -- | @1 mebibyte = 1024 kibibytes@ mebibytes :: Integral n => Size -> n -mebibytes = (`div` 1024) . kibibytes -- | @1 gibibyte = 1024 mebibytes@ gibibytes :: Integral n => Size -> n -gibibytes = (`div` 1024) . mebibytes -- | @1 tebibyte = 1024 gibibytes@ tebibytes :: Integral n => Size -> n -tebibytes = (`div` 1024) . gibibytes {-| Count the number of characters in the stream (like @wc -c@) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/turtle-1.5.16/src/Turtle/Shell.hs new/turtle-1.5.19/src/Turtle/Shell.hs --- old/turtle-1.5.16/src/Turtle/Shell.hs 2020-01-20 18:52:57.000000000 +0100 +++ new/turtle-1.5.19/src/Turtle/Shell.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,3 +1,4 @@ +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE CPP #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE RankNTypes #-} @@ -101,21 +102,23 @@ -- | A @(Shell a)@ is a protected stream of @a@'s with side effects newtype Shell a = Shell { _foldShell:: forall r . FoldShell a r -> IO r } +data Maybe' a = Just' !a | Nothing' + translate :: FoldM IO a b -> FoldShell a b -translate (FoldM step begin done) = FoldShell step' Nothing done' +translate (FoldM step begin done) = FoldShell step' Nothing' done' where - step' Nothing a = do + step' Nothing' a = do x <- begin x' <- step x a - return (Just x') - step' (Just x) a = do + return $! Just' x' + step' (Just' x) a = do x' <- step x a - return (Just x') + return $! Just' x' - done' Nothing = do + done' Nothing' = do x <- begin done x - done' (Just x) = do + done' (Just' x) = do done x -- | Use a @`FoldM` `IO`@ to reduce the stream of @a@'s produced by a `Shell` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/turtle-1.5.16/src/Turtle/Tutorial.hs new/turtle-1.5.19/src/Turtle/Tutorial.hs --- old/turtle-1.5.16/src/Turtle/Tutorial.hs 2020-01-20 18:52:57.000000000 +0100 +++ new/turtle-1.5.19/src/Turtle/Tutorial.hs 2001-09-09 03:46:40.000000000 +0200 @@ -116,6 +116,9 @@ -- * Conclusion -- $conclusion + -- * Nix scripts + -- $nix + -- * FAQ -- $faq ) where @@ -1796,6 +1799,31 @@ -- still benefit from adding more utilities for better parity with the Unix -- ecosystem. Pull requests to add new utilities are highly welcome! +-- $nix +-- +-- You can also turn `turtle` scripts into runnable scripts using Nix, like +-- this: +-- +-- > #! /usr/bin/env nix-shell +-- > #! nix-shell -i runghc --packages "ghc.withPackages (x: [ x.turtle ])" +-- > +-- > {-# LANGUAGE OverloadedStrings #-} +-- > +-- > import Turtle +-- > +-- > main = echo "Hello, world!" +-- +-- ... or create an auto-reloading script like this: +-- +-- > #! /usr/bin/env nix-shell +-- > #! nix-shell -i "ghcid -T main" --packages ghcid "ghc.withPackages (x: [ x.turtle ])" +-- > +-- > {-# LANGUAGE OverloadedStrings #-} +-- > +-- > import Turtle +-- > +-- > main = echo "Hello, world!" + -- $faq -- -- These are the most frequently asked questions from new users: @@ -1853,3 +1881,4 @@ -- like this: -- -- > Turtle.system (System.Process.proc "/bin/sh" []) empty + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/turtle-1.5.16/turtle.cabal new/turtle-1.5.19/turtle.cabal --- old/turtle-1.5.16/turtle.cabal 2020-01-20 18:52:57.000000000 +0100 +++ new/turtle-1.5.19/turtle.cabal 2001-09-09 03:46:40.000000000 +0200 @@ -1,5 +1,5 @@ Name: turtle -Version: 1.5.16 +Version: 1.5.19 Cabal-Version: >=1.10 Build-Type: Simple License: BSD3 @@ -7,7 +7,6 @@ Copyright: 2015 Gabriel Gonzalez Author: Gabriel Gonzalez Maintainer: [email protected] -Tested-With: GHC == 7.10.2, GHC == 8.0.1 Bug-Reports: https://github.com/Gabriel439/Haskell-Turtle-Library/issues Synopsis: Shell programming, Haskell-style Description: @turtle@ is a reimplementation of the Unix command line environment @@ -55,7 +54,7 @@ bytestring >= 0.9.1.8 && < 0.11, clock >= 0.4.1.2 && < 0.9 , containers >= 0.5.0.0 && < 0.7 , - directory >= 1.0.7 && < 1.4 , + directory >= 1.3.1.0 && < 1.4 , exceptions >= 0.4 && < 0.11, foldl >= 1.1 && < 1.5 , hostname < 1.1 ,
