intervals 0.9 → 0.9.1
raw patch · 8 files changed
+88/−53 lines, 8 filesdep +semigroupsdep ~doctest
Dependencies added: semigroups
Dependency ranges changed: doctest
Files
- .hlint.yaml +12/−0
- .travis.yml +36/−36
- CHANGELOG.markdown +6/−0
- HLint.hs +0/−12
- intervals.cabal +5/−2
- src/Numeric/Interval/Internal.hs +11/−0
- src/Numeric/Interval/Kaucher.hs +12/−2
- src/Numeric/Interval/NonEmpty/Internal.hs +6/−1
+ .hlint.yaml view
@@ -0,0 +1,12 @@+- arguments: [--cpp-define=HLINT, --cpp-ansi]++# not viable+- ignore: {name: Reduce duplication}++# don't want to!+- ignore: {name: Use infix}++# these don't consider the corner cases when using doubles+- ignore: {name: "Use >"}+- ignore: {name: "Use <="}+- ignore: {name: "Use >="}
.travis.yml view
@@ -4,7 +4,7 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci #-# version: 0.3.20190425+# version: 0.5.20180830 # language: c dist: xenial@@ -35,44 +35,43 @@ include: - compiler: ghc-8.8.1 addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}- env: GHCHEAD=true - compiler: ghc-8.6.5- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-3.0"]}} - compiler: ghc-8.4.4- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-3.0"]}} - compiler: ghc-8.2.2- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-3.0"]}} - compiler: ghc-8.0.2- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-3.0"]}} - compiler: ghc-7.10.3- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-3.0"]}} - compiler: ghc-7.8.4- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-3.0"]}} - compiler: ghc-7.6.3- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-3.0"]}} - compiler: ghc-7.4.2- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.2","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.2","cabal-install-3.0"]}} - compiler: ghc-7.2.2- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.2.2","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.2.2","cabal-install-3.0"]}} - compiler: ghc-7.0.4- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.0.4","cabal-install-2.4"]}}+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.0.4","cabal-install-3.0"]}} - compiler: ghc-head addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-head","cabal-install-head"]}}- env: GHCHEAD=true allow_failures: - compiler: ghc-head - compiler: ghc-7.0.4 - compiler: ghc-7.2.2- - compiler: ghc-8.8.1 before_install: - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')+ - WITHCOMPILER="-w $HC"+ - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//') - HCPKG="$HC-pkg" - unset CC - CABAL=/opt/ghc/bin/cabal - CABALHOME=$HOME/.cabal - export PATH="$CABALHOME/bin:$PATH" - TOP=$(pwd)- - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))+ - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')" - echo $HCNUMVER - CABAL="$CABAL -vnormal+nowrap+markoutput" - set -o pipefail@@ -100,11 +99,13 @@ - TEST=--enable-tests - if [ $HCNUMVER -lt 70600 ] ; then TEST=--disable-tests ; fi - BENCH=--enable-benchmarks- - GHCHEAD=${GHCHEAD-false}+ - HEADHACKAGE=false+ - if [ $HCNUMVER -gt 80801 ] ; then HEADHACKAGE=true ; fi - rm -f $CABALHOME/config - | echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config echo "remote-build-reporting: anonymous" >> $CABALHOME/config+ echo "write-ghc-environment-files: always" >> $CABALHOME/config echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config echo "world-file: $CABALHOME/world" >> $CABALHOME/config@@ -118,15 +119,14 @@ echo "repository hackage.haskell.org" >> $CABALHOME/config echo " url: http://hackage.haskell.org/" >> $CABALHOME/config - |- if $GHCHEAD; then+ if $HEADHACKAGE; then echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config- - echo "repository head.hackage" >> $CABALHOME/config- echo " url: http://head.hackage.haskell.org/" >> $CABALHOME/config+ echo "repository head.hackage.ghc.haskell.org" >> $CABALHOME/config+ echo " url: https://ghc.gitlab.haskell.org/head.hackage/" >> $CABALHOME/config echo " secure: True" >> $CABALHOME/config- echo " root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config- echo " 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config- echo " 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config+ echo " root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d" >> $CABALHOME/config+ echo " 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329" >> $CABALHOME/config+ echo " f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89" >> $CABALHOME/config echo " key-threshold: 3" >> $CABALHOME/config fi - cat $CABALHOME/config@@ -136,17 +136,16 @@ - rm -rf cabal.project cabal.project.local cabal.project.freeze - touch cabal.project - |- echo 'packages: "."' >> cabal.project+ echo "packages: ." >> cabal.project - |- echo "write-ghc-environment-files: always" >> cabal.project- - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(intervals)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(intervals)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done" - cat cabal.project || true - cat cabal.project.local || true - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi- - ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH} | color_cabal_output+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'" - rm cabal.project.freeze- - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all | color_cabal_output+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output script: - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) # Packaging...@@ -154,26 +153,27 @@ # Unpacking... - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/ - cd ${DISTDIR} || false- - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;+ - PKGDIR_intervals="$(find . -maxdepth 1 -type d -regex '.*/intervals-[0-9.]*')" # Generate cabal.project - rm -rf cabal.project cabal.project.local cabal.project.freeze - touch cabal.project - |- echo 'packages: "intervals-*/*.cabal"' >> cabal.project+ echo "packages: ${PKGDIR_intervals}" >> cabal.project - |- echo "write-ghc-environment-files: always" >> cabal.project- - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(intervals)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(intervals)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done" - cat cabal.project || true - cat cabal.project.local || true # Building with tests and benchmarks... # build & run tests, build benchmarks- - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output # Testing...- - if [ $HCNUMVER -ge 70600 ] ; then ${CABAL} v2-test -w ${HC} ${TEST} ${BENCH} all | color_cabal_output ; fi+ - if [ $HCNUMVER -ge 70600 ] ; then ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output ; fi # cabal check...- - (cd intervals-* && ${CABAL} -vnormal check)+ - (cd ${PKGDIR_intervals} && ${CABAL} -vnormal check) # haddock...- - ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+ - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all | color_cabal_output # REGENDATA ["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"] # EOF
CHANGELOG.markdown view
@@ -1,3 +1,9 @@+0.9.1 [2020.01.29]+------------------+* Add `Semigroup` instances for the `Interval` types in `Numeric.Interval`,+ `Numeric.Interval.Kaucher`, and `Numeric.Interval.NonEmpty`.+ Add a `Monoid` instance for the `Interval` type in `Numeric.Interval`.+ 0.9 [2019.05.10] ---------------- * Remove the `Foldable` instances for the `Interval` types from
− HLint.hs
@@ -1,12 +0,0 @@-import "hint" HLint.HLint---- not viable-ignore "Reduce duplication"---- don't want to!-ignore "Use infix"---- these don't consider the corner cases when using doubles-ignore "Use >"-ignore "Use <="-ignore "Use >="
intervals.cabal view
@@ -1,5 +1,5 @@ name: intervals-version: 0.9+version: 0.9.1 synopsis: Interval Arithmetic description: A 'Numeric.Interval.Interval' is a closed, convex set of floating point values.@@ -29,10 +29,10 @@ , GHC == 8.6.5 , GHC == 8.8.1 extra-source-files:+ .hlint.yaml .travis.yml CHANGELOG.markdown README.markdown- HLint.hs Warning.hs source-repository head@@ -74,6 +74,9 @@ if impl(ghc >=7.4) build-depends: ghc-prim++ if !impl(ghc >=8.0)+ build-depends: semigroups >=0.11 && <1 ghc-options: -Wall -O2
src/Numeric/Interval/Internal.hs view
@@ -65,6 +65,9 @@ import Numeric.Interval.Exception import Prelude hiding (null, elem, notElem) +import qualified Data.Semigroup+import qualified Data.Monoid+ -- $setup data Interval a = I !a !a | Empty deriving@@ -78,6 +81,14 @@ #endif #endif )++-- | 'Data.Semigroup.<>' is 'hull'+instance Ord a => Data.Semigroup.Semigroup (Interval a) where+ (<>) = hull++instance Ord a => Data.Monoid.Monoid (Interval a) where+ mempty = empty+ mappend = (Data.Semigroup.<>) infix 3 ... infixl 6 +/-
src/Numeric/Interval/Kaucher.hs view
@@ -65,7 +65,6 @@ #endif ) import Data.Function (on)-import Data.Monoid import Data.Traversable #if __GLASGOW_HASKELL__ >= 704 import GHC.Generics@@ -73,6 +72,9 @@ import Numeric.Interval.Exception import Prelude hiding (null, elem, notElem) +import qualified Data.Semigroup+import qualified Data.Monoid+ -- $setup data Interval a = I !a !a deriving@@ -87,12 +89,16 @@ #endif ) +-- | 'Data.Semigroup.<>' is 'hull'+instance Ord a => Data.Semigroup.Semigroup (Interval a) where+ (<>) = hull+ instance Functor Interval where fmap f (I a b) = I (f a) (f b) {-# INLINE fmap #-} instance Foldable Interval where- foldMap f (I a b) = f a `mappend` f b+ foldMap f (I a b) = f a `Data.Monoid.mappend` f b {-# INLINE foldMap #-} instance Traversable Interval where@@ -662,6 +668,10 @@ -- -- >>> hull (15 ... 85 :: Interval Double) (0 ... 10 :: Interval Double) -- 0.0 ... 85.0+--+-- >>> hull (10 ... 20 :: Interval Double) (15 ... 0 :: Interval Double)+-- 10.0 ... 20.0+-- hull :: Ord a => Interval a -> Interval a -> Interval a hull x@(I a b) y@(I a' b') | null x = y
src/Numeric/Interval/NonEmpty/Internal.hs view
@@ -58,9 +58,10 @@ #if __GLASGOW_HASKELL__ >= 704 import GHC.Generics #endif-import Numeric.Interval.Exception import Prelude hiding (null, elem, notElem) +import qualified Data.Semigroup+ -- $setup -- >>> import Test.QuickCheck.Arbitrary -- >>> import Test.QuickCheck.Gen hiding (scale)@@ -88,6 +89,10 @@ #endif #endif )++-- | 'Data.Semigroup.<>' is 'hull'+instance Ord a => Data.Semigroup.Semigroup (Interval a) where+ (<>) = hull infix 3 ...