extra 1.4.2 → 1.4.3
raw patch · 9 files changed
+56/−4 lines, 9 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Version.Extra: makeVersion :: [Int] -> Version
+ Data.Version.Extra: readVersion :: String -> Version
+ Extra: makeVersion :: [Int] -> Version
+ Extra: readVersion :: String -> Version
Files
- CHANGES.txt +2/−0
- LICENSE +1/−1
- README.md +1/−1
- extra.cabal +3/−2
- src/Data/Version/Extra.hs +35/−0
- src/Extra.hs +4/−0
- src/System/Directory/Extra.hs +2/−0
- test/TestGen.hs +3/−0
- test/TestUtil.hs +5/−0
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for Extra +1.4.3+ Add Data.Version.Extra 1.4.2 Make concatMapM/mapMaybeM faster 1.4.1
LICENSE view
@@ -1,4 +1,4 @@-Copyright Neil Mitchell 2014-2015.+Copyright Neil Mitchell 2014-2016. All rights reserved. Redistribution and use in source and binary forms, with or without
README.md view
@@ -1,4 +1,4 @@-# Extra [](https://hackage.haskell.org/package/extra) [](https://travis-ci.org/ndmitchell/extra)+# Extra [](https://hackage.haskell.org/package/extra) [](https://www.stackage.org/package/extra) [](https://travis-ci.org/ndmitchell/extra) [](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,13 +1,13 @@ cabal-version: >= 1.10 build-type: Simple name: extra-version: 1.4.2+version: 1.4.3 license: BSD3 license-file: LICENSE category: Development author: Neil Mitchell <ndmitchell@gmail.com> maintainer: Neil Mitchell <ndmitchell@gmail.com>-copyright: Neil Mitchell 2014-2015+copyright: Neil Mitchell 2014-2016 synopsis: Extra functions I use. description: 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.@@ -48,6 +48,7 @@ Data.IORef.Extra Data.List.Extra Data.Tuple.Extra+ Data.Version.Extra Numeric.Extra System.Directory.Extra System.Environment.Extra
+ src/Data/Version/Extra.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}++-- | This module extends "Data.Version" with extra utilities.+-- The package also exports the existing "Data.Version" functions.+module Data.Version.Extra(+ module Data.Version,+ makeVersion, readVersion+ ) where++import Data.Version+import Data.List.Extra+import Text.ParserCombinators.ReadP+++#if __GLASGOW_HASKELL__ < 710++-- | Construct tag-less 'Version'+--+-- > showVersion (makeVersion [1,2,3]) == "1.2.3"+makeVersion :: [Int] -> Version+makeVersion b = Version b []++#endif++-- | Read a 'Version' or throw an exception.+--+-- > \x -> readVersion (showVersion x) == x+-- > readVersion "hello" == undefined+readVersion :: String -> Version+readVersion s =+ case [ x | (x,"") <- readP_to_S parseVersion $ trimEnd s] of+ [x] -> x+ [] -> error "Data.Version.Extra.readVersion: no parse"+ _ -> error "Data.Version.Extra.readVersion: ambiguous parse"
src/Extra.hs view
@@ -24,6 +24,9 @@ -- * Data.Tuple.Extra -- | Extra functions available in @"Data.Tuple.Extra"@. first, second, (***), (&&&), dupe, both, fst3, snd3, thd3,+ -- * Data.Version.Extra+ -- | Extra functions available in @"Data.Version.Extra"@.+ makeVersion, readVersion, -- * Numeric.Extra -- | Extra functions available in @"Numeric.Extra"@. showDP, intToDouble, intToFloat, floatToDouble, doubleToFloat,@@ -54,6 +57,7 @@ import Data.IORef.Extra import Data.List.Extra import Data.Tuple.Extra+import Data.Version.Extra import Numeric.Extra import System.Directory.Extra import System.Environment.Extra
src/System/Directory/Extra.hs view
@@ -24,7 +24,9 @@ import Control.Monad.Extra import System.FilePath import Data.List+#if !MIN_VERSION_directory(1,2,3) import Control.Exception+#endif #ifndef mingw32_HOST_OS import qualified System.Posix
test/TestGen.hs view
@@ -183,6 +183,9 @@ testGen "(succ &&& pred) 1 == (2,0)" $ (succ &&& pred) 1 == (2,0) testGen "dupe 12 == (12, 12)" $ dupe 12 == (12, 12) testGen "both succ (1,2) == (2,3)" $ both succ (1,2) == (2,3)+ testGen "showVersion (makeVersion [1,2,3]) == \"1.2.3\"" $ showVersion (makeVersion [1,2,3]) == "1.2.3"+ testGen "\\x -> readVersion (showVersion x) == x" $ \x -> readVersion (showVersion x) == x+ testGen "readVersion \"hello\" == undefined" $ erroneous $ readVersion "hello" testGen "showDP 4 pi == \"3.1416\"" $ showDP 4 pi == "3.1416" testGen "showDP 0 pi == \"3\"" $ showDP 0 pi == "3" testGen "showDP 2 3 == \"3.00\"" $ showDP 2 3 == "3.00"
test/TestUtil.hs view
@@ -7,6 +7,7 @@ import Control.Exception.Extra import Data.Either.Extra import System.IO.Extra+import Data.Version.Extra import Data.IORef import System.IO.Unsafe import Data.Time.Clock@@ -20,6 +21,7 @@ import Data.List as X import Data.Char as X import Data.Tuple as X+import Data.Version as X import System.Directory as X import System.FilePath as X import System.Info as X@@ -97,3 +99,6 @@ instance Arbitrary DiffTime where arbitrary = fmap realToFrac $ choose (0 :: Double, 86401)++instance Arbitrary Version where+ arbitrary = makeVersion . map abs <$> listOf1 arbitrary