packages feed

extra 1.6.6 → 1.6.7

raw patch · 10 files changed

+40/−19 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Monad.Extra: fold1M :: (Partial, Monad m) => (a -> a -> m a) -> [a] -> m a
+ Control.Monad.Extra: fold1M_ :: (Partial, Monad m) => (a -> a -> m a) -> [a] -> m ()
+ Extra: fold1M :: (Partial, Monad m) => (a -> a -> m a) -> [a] -> m a
+ Extra: fold1M_ :: (Partial, Monad m) => (a -> a -> m a) -> [a] -> m ()

Files

CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for Extra +1.6.7, released 2018-05-23+    #35, add fold1M and fold1M_+    #34, lots of documentation typos 1.6.6, released 2018-04-16     Add escapeJSON and unescapeJSON     Add escapeHTML and unescapeHTML
README.md view
@@ -1,4 +1,4 @@-# Extra [![Hackage version](https://img.shields.io/hackage/v/extra.svg?label=Hackage)](https://hackage.haskell.org/package/extra) [![Stackage version](https://www.stackage.org/package/extra/badge/lts?label=Stackage)](https://www.stackage.org/package/extra) [![Linux Build Status](https://img.shields.io/travis/ndmitchell/extra.svg?label=Linux%20build)](https://travis-ci.org/ndmitchell/extra) [![Windows Build Status](https://img.shields.io/appveyor/ci/ndmitchell/extra.svg?label=Windows%20build)](https://ci.appveyor.com/project/ndmitchell/extra)+# Extra [![Hackage version](https://img.shields.io/hackage/v/extra.svg?label=Hackage)](https://hackage.haskell.org/package/extra) [![Stackage version](https://www.stackage.org/package/extra/badge/nightly?label=Stackage)](https://www.stackage.org/package/extra) [![Linux Build Status](https://img.shields.io/travis/ndmitchell/extra/master.svg?label=Linux%20build)](https://travis-ci.org/ndmitchell/extra) [![Windows Build Status](https://img.shields.io/appveyor/ci/ndmitchell/extra/master.svg?label=Windows%20build)](https://ci.appveyor.com/project/ndmitchell/extra)  A library of extra functions for the standard Haskell libraries. Most functions are simple additions, filling out missing functionality. A few functions are available in later versions of GHC, but this package makes them available back to GHC 7.2. A few examples: 
extra.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.18 build-type:         Simple name:               extra-version:            1.6.6+version:            1.6.7 license:            BSD3 license-file:       LICENSE category:           Development@@ -15,7 +15,7 @@     The module "Extra" documents all functions provided by this library. Modules such as "Data.List.Extra" provide extra functions over "Data.List" and also reexport "Data.List". Users are recommended to replace "Data.List" imports with "Data.List.Extra" if they need the extra functionality. homepage:           https://github.com/ndmitchell/extra#readme bug-reports:        https://github.com/ndmitchell/extra/issues-tested-with:        GHC==8.4.1, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2+tested-with:        GHC==8.4.2, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2  extra-doc-files:     CHANGES.txt
src/Control/Concurrent/Extra.hs view
@@ -62,7 +62,7 @@ -- called with asynchronous exceptions masked. -- -- @--- forkFinally action and_then =+-- 'forkFinally' action and_then = --    mask $ \restore -> --      forkIO $ try (restore action) >>= and_then -- @@@ -116,8 +116,8 @@ --------------------------------------------------------------------- -- LOCK --- | Like an MVar, but has no value.---   Used to guarantees single-threaded access, typically to some system resource. +-- | Like an 'MVar', but has no value.+--   Used to guarantee single-threaded access, typically to some system resource. --   As an example: -- -- @@@ -128,7 +128,7 @@ -- @ -- --   Here we are creating a lock to ensure that when writing output our messages---   do not get interleaved. This use of MVar never blocks on a put. It is permissible,+--   do not get interleaved. This use of 'MVar' never blocks on a put. It is permissible, --   but rare, that a withLock contains a withLock inside it - but if so, --   watch out for deadlocks. @@ -155,23 +155,23 @@ --------------------------------------------------------------------- -- VAR --- | Like an MVar, but must always be full.---   Used to on a mutable variable in a thread-safe way.+-- | Like an 'MVar', but must always be full.+--   Used to operate on a mutable variable in a thread-safe way. --   As an example: -- -- @ -- hits <- 'newVar' 0 -- forkIO $ do ...; 'modifyVar_' hits (+1); ... -- i <- 'readVar' hits--- print ("HITS",i)+-- print (\"HITS\",i) -- @ -- --   Here we have a variable which we modify atomically, so modifications are---   not interleaved. This use of MVar never blocks on a put. No modifyVar+--   not interleaved. This use of 'MVar' never blocks on a put. No modifyVar --   operation should ever block, and they should always complete in a reasonable---   timeframe. A Var should not be used to protect some external resource, only---   the variable contained within. Information from a readVar should not be subsequently---   inserted back into the Var.+--   timeframe. A 'Var' should not be used to protect some external resource, only+--   the variable contained within. Information from a 'readVar' should not be subsequently+--   inserted back into the 'Var'. newtype Var a = Var (MVar a)  -- | Create a new 'Var' with a value.
src/Control/Monad/Extra.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE ConstraintKinds #-}  -- | Extra functions for "Control.Monad". --   These functions provide looping, list operations and booleans.@@ -12,11 +13,13 @@     loopM, whileM,     -- * Lists     partitionM, concatMapM, concatForM, mconcatMapM, mapMaybeM, findM, firstJustM,+    fold1M, fold1M_,     -- * Booleans     whenM, unlessM, ifM, notM, (||^), (&&^), orM, andM, anyM, allM     ) where  import Control.Monad+import Control.Exception.Extra import Data.Maybe import Control.Applicative import Data.Monoid@@ -51,6 +54,19 @@ -- | Monadic generalisation of 'either'. eitherM :: Monad m => (a -> m c) -> (b -> m c) -> m (Either a b) -> m c eitherM l r x = either l r =<< x++-- | A variant of 'foldM' that has no base case, and thus may only be applied to non-empty lists.+--+-- > fold1M (\x y -> Just x) [] == undefined+-- > fold1M (\x y -> Just $ x + y) [1, 2, 3] == Just 6+fold1M :: (Partial, Monad m) => (a -> a -> m a) -> [a] -> m a+fold1M f (x:xs) = foldM f x xs+fold1M f xs = error "fold1M: empty list"++-- | Like 'fold1M' but discards the result.+fold1M_ :: (Partial, Monad m) => (a -> a -> m a) -> [a] -> m ()+fold1M_ f xs = fold1M f xs >> return ()+  -- Data.List for Monad 
src/Data/List/Extra.hs view
@@ -255,7 +255,7 @@   -- | Split the first word off a string. Useful for when starting to parse the beginning---   of a string, but you want to accurately perserve whitespace in the rest of the string.+--   of a string, but you want to accurately preserve whitespace in the rest of the string. -- -- > word1 "" == ("", "") -- > word1 "keyword rest of string" == ("keyword","rest of string")
src/Extra.hs view
@@ -14,7 +14,7 @@     Partial, retry, retryBool, errorWithoutStackTrace, showException, stringException, errorIO, displayException, ignore, catch_, handle_, try_, catchJust_, handleJust_, tryJust_, catchBool, handleBool, tryBool,     -- * Control.Monad.Extra     -- | Extra functions available in @"Control.Monad.Extra"@.-    whenJust, whenJustM, unit, maybeM, eitherM, loopM, whileM, partitionM, concatMapM, concatForM, mconcatMapM, mapMaybeM, findM, firstJustM, whenM, unlessM, ifM, notM, (||^), (&&^), orM, andM, anyM, allM,+    whenJust, whenJustM, unit, maybeM, eitherM, loopM, whileM, partitionM, concatMapM, concatForM, mconcatMapM, mapMaybeM, findM, firstJustM, fold1M, fold1M_, whenM, unlessM, ifM, notM, (||^), (&&^), orM, andM, anyM, allM,     -- * Data.Either.Extra     -- | Extra functions available in @"Data.Either.Extra"@.     isLeft, isRight, fromLeft, fromRight, fromEither, fromLeft', fromRight', eitherToMaybe, maybeToEither,
src/System/Process/Extra.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE TupleSections, ConstraintKinds #-}  -- | Extra functions for creating processes. Specifically variants that automatically check---   the 'ExitCode' and capture the 'stdout'\/'stderr' handles.+--   the 'ExitCode' and capture the 'stdout' \/ 'stderr' handles. module System.Process.Extra(     module System.Process,     system_, systemOutput, systemOutput_
src/System/Time/Extra.hs view
@@ -71,7 +71,7 @@   -- | Show a number of seconds, typically a duration, in a suitable manner with---   responable precision for a human.+--   reasonable precision for a human. -- -- > showDuration 3.435   == "3.44s" -- > showDuration 623.8   == "10m24s"@@ -99,7 +99,7 @@         return $ 1e-9 * fromIntegral (toNanoSecs $ end - start)     where time = getTime Monotonic -{-# DEPRECATED offsetTimeIncrease "Use offsetTime instead, which is guaranteed to always increase." #-}+{-# DEPRECATED offsetTimeIncrease "Use 'offsetTime' instead, which is guaranteed to always increase." #-}  -- | A synonym for 'offsetTime'. offsetTimeIncrease :: IO (IO Seconds)
test/TestGen.hs view
@@ -26,6 +26,8 @@     testGen "whenJust Nothing  print == return ()" $ whenJust Nothing  print == return ()     testGen "whenJust (Just 1) print == print 1" $ whenJust (Just 1) print == print 1     testGen "\\(x :: Maybe ()) -> unit x == x" $ \(x :: Maybe ()) -> unit x == x+    testGen "fold1M (\\x y -> Just x) [] == undefined" $ erroneous $ fold1M (\x y -> Just x) []+    testGen "fold1M (\\x y -> Just $ x + y) [1, 2, 3] == Just 6" $ fold1M (\x y -> Just $ x + y) [1, 2, 3] == Just 6     testGen "partitionM (Just . even) [1,2,3] == Just ([2], [1,3])" $ partitionM (Just . even) [1,2,3] == Just ([2], [1,3])     testGen "partitionM (const Nothing) [1,2,3] == Nothing" $ partitionM (const Nothing) [1,2,3] == Nothing     testGen "Just True  ||^ undefined  == Just True" $ Just True  ||^ undefined  == Just True