packages feed

ascii-progress 0.1.0.3 → 0.1.1.0

raw patch · 2 files changed

+26/−8 lines, 2 filesdep −MissingHPVP ok

version bump matches the API change (PVP)

Dependencies removed: MissingH

API changes (from Hackage documentation)

+ System.Console.AsciiProgress.Internal: replace :: Eq a => [a] -> [a] -> [a] -> [a]

Files

ascii-progress.cabal view
@@ -1,5 +1,5 @@ name:                ascii-progress-version:             0.1.0.3+version:             0.1.1.0 synopsis:            A simple progress bar for the console. description:     A simple Haskell progress bar for the console. Heavily borrows from TJ@@ -21,8 +21,7 @@ library   exposed-modules:     System.Console.AsciiProgress                      , System.Console.AsciiProgress.Internal-  build-depends:       MissingH-                     , ansi-terminal+  build-depends:       ansi-terminal                      , async >= 2.0.1.5                      , base >=4.7 && <4.8                      , data-default >= 0.5.3@@ -32,8 +31,7 @@  executable example   main-is:             Example.hs-  build-depends:       MissingH-                     , ansi-terminal+  build-depends:       ansi-terminal                      , async >= 2.0.1.5                      , base >=4.7 && <4.8                      , data-default >= 0.5.3@@ -45,8 +43,7 @@ test-suite hspec   type:                exitcode-stdio-1.0   main-is: Spec.hs-  build-depends:       MissingH-                     , ansi-terminal+  build-depends:       ansi-terminal                      , async >= 2.0.1.5                      , base >=4.7 && <4.8                      , data-default >= 0.5.3
lib/System/Console/AsciiProgress/Internal.hs view
@@ -6,7 +6,6 @@ import Control.Concurrent (Chan, MVar, newChan, newEmptyMVar, newMVar,                            readMVar, tryPutMVar, tryReadMVar) import Data.Default (Default(..))-import Data.List.Utils (replace) import Data.Time.Clock import Text.Printf @@ -147,6 +146,28 @@ -- "bazbiz" replaceMany :: Eq a => [([a], [a])] -> [a] -> [a] replaceMany pairs target = foldr (uncurry replace) target pairs++-- |+-- Replaces a subsequence by another in a sequence+--+-- Taken from http://bluebones.net/2007/01/replace-in-haskell/+--+-- >>> replace "foo" "baz" "foobar"+-- "bazbar"+-- >>> replace "some" "thing" "something something"+-- "thingthing thingthing"+-- >>> replace "not" "" "something"+-- "something"+-- >>> replace "" "here" "something"+-- "heresomething"+replace :: Eq a => [a] -> [a] -> [a] -> [a]+replace _ _ [] = []+replace [] new target = new ++ target+replace old new target@(t:ts) =+  if take len target == old+      then new ++ replace old new (drop len target)+      else t : replace old new ts+  where len = length old  -- | -- Forces an MVar's contents to be read or swaped by a default value, even if