packages feed

approximate 0.3.1 → 0.3.5

raw patch · 14 files changed

Files

.gitignore view
@@ -1,4 +1,5 @@ dist+dist-newstyle docs wiki TAGS@@ -11,3 +12,21 @@ *.hi *~ *#+.stack-work/+cabal-dev+*.chi+*.chs.h+*.dyn_o+*.dyn_hi+.hpc+.hsenv+.cabal-sandbox/+cabal.sandbox.config+*.prof+*.aux+*.hp+*.eventlog+cabal.project.local+cabal.project.local~+.HTF/+.ghc.environment.*
+ .hlint.yaml view
@@ -0,0 +1,4 @@+- arguments: [--cpp-ansi]++- ignore: {name: Use import/export shortcut}+- ignore: {name: Use fmap}
− .travis.yml
@@ -1,97 +0,0 @@-# This file has been generated -- see https://github.com/hvr/multi-ghc-travis-language: c-sudo: false--cache:-  directories:-    - $HOME/.cabsnap-    - $HOME/.cabal/packages--before_cache:-  - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log-  - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar--matrix:-  include:-    # some doctests require type-level tricks, only in GHC >=7.8-    - env: CABALVER=1.24 GHCVER=7.4.2 TEST=--disable-tests-      compiler: ": #GHC 7.4.2"-      addons: {apt: {packages: [cabal-install-1.24,ghc-7.4.2], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=7.6.3 TEST=--disable-tests-      compiler: ": #GHC 7.6.3"-      addons: {apt: {packages: [cabal-install-1.24,ghc-7.6.3], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=7.8.4-      compiler: ": #GHC 7.8.4"-      addons: {apt: {packages: [cabal-install-1.24,ghc-7.8.4], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=7.10.3-      compiler: ": #GHC 7.10.3"-      addons: {apt: {packages: [cabal-install-1.24,ghc-7.10.3], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=8.0.2-      compiler: ": #GHC 8.0.2"-      addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2], sources: [hvr-ghc]}}--before_install:- - unset CC- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH- - TEST=${TEST---enable-tests}--install:- - cabal --version- - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"- - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];-   then-     zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >-          $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;-   fi- - travis_retry cabal update -v- - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config- - cabal install --only-dependencies $TEST --dry -v > installplan.txt- - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt--# check whether current requested install-plan matches cached package-db snapshot- - if diff -u $HOME/.cabsnap/installplan.txt installplan.txt;-   then-     echo "cabal build-cache HIT";-     rm -rfv .ghc;-     cp -a $HOME/.cabsnap/ghc $HOME/.ghc;-     cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;-   else-     echo "cabal build-cache MISS";-     rm -rf $HOME/.cabsnap;-     mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;-     cabal install -j --only-dependencies $TEST;-   fi--# snapshot package-db on cache miss- - if [ ! -d $HOME/.cabsnap ];-   then-      echo "snapshotting package-db to build-cache";-      mkdir $HOME/.cabsnap;-      cp -a $HOME/.ghc $HOME/.cabsnap/ghc;-      cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;-   fi--# Here starts the actual work to be performed for the package under test;-# any command which exits with a non-zero exit code causes the build to fail.-script:- - if [ -f configure.ac ]; then autoreconf -i; fi- - cabal configure $TEST -v2  # -v2 provides useful information for debugging- - cabal build   # this builds all libraries and executables (including tests/benchmarks)- - if [ $TEST = "--enable-tests" ]; then cabal test; fi- - cabal sdist   # tests that a source-distribution can be generated--# Check that the resulting source distribution can be built & installed.-# If there are no other `.tar.gz` files in `dist`, this can be even simpler:-# `cabal install --force-reinstalls dist/*-*.tar.gz`- - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&-   (cd dist && cabal install --force-reinstalls "$SRC_TGZ")--notifications:-  irc:-    channels:-      - "irc.freenode.org#haskell-lens"-    skip_join: true-    template:-      - "\x0313approximate\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"--# EOF
CHANGELOG.markdown view
@@ -1,3 +1,25 @@+0.3.5 [2021.11.16]+------------------+* Add `Eq1` instances for `Approximate` and `Mass`.+* Allow building with `hashable-1.4.*`.+* Drop support for pre-8.0 versions of GHC.++0.3.4 [2021.02.21]+------------------+* Fix the build with `safecopy-0.10.4` or later.++0.3.3 [2021.02.17]+------------------+* Allow building with `lens-5.*`.+* The build-type has been changed from `Custom` to `Simple`.+  To achieve this, the `doctests` test suite has been removed in favor of using+  [`cabal-docspec`](https://github.com/phadej/cabal-extras/tree/master/cabal-docspec)+  to run the doctests.++0.3.2 [2019.09.13]+------------------+* Allow building with `safecopy-0.10`.+ 0.3.1 ----- * Add a library dependency on the `doctests` test suite
− HLint.hs
@@ -1,1 +0,0 @@-ignore "Use import/export shortcut"
README.markdown view
@@ -1,7 +1,7 @@ approximate =========== -[![Hackage](https://img.shields.io/hackage/v/approximate.svg)](https://hackage.haskell.org/package/approximate) [![Build Status](https://secure.travis-ci.org/ekmett/approximate.png?branch=master)](http://travis-ci.org/ekmett/approximate)+[![Hackage](https://img.shields.io/hackage/v/approximate.svg)](https://hackage.haskell.org/package/approximate) [![Build Status](https://github.com/ekmett/approximate/workflows/Haskell-CI/badge.svg)](https://github.com/ekmett/approximate/actions?query=workflow%3AHaskell-CI)  This package provides approximate numbers and discrete values with lower bounds on their probability of correctness. 
Setup.lhs view
@@ -1,34 +1,7 @@-\begin{code}-{-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -Wall #-}-module Main (main) where--#ifndef MIN_VERSION_cabal_doctest-#define MIN_VERSION_cabal_doctest(x,y,z) 0-#endif--#if MIN_VERSION_cabal_doctest(1,0,0)--import Distribution.Extra.Doctest ( defaultMainWithDoctests )-main :: IO ()-main = defaultMainWithDoctests "doctests"--#else--#ifdef MIN_VERSION_Cabal--- If the macro is defined, we have new cabal-install,--- but for some reason we don't have cabal-doctest in package-db------ Probably we are running cabal sdist, when otherwise using new-build--- workflow-import Warning ()-#endif--import Distribution.Simple--main :: IO ()-main = defaultMain+#!/usr/bin/runhaskell+> module Main (main) where -#endif+> import Distribution.Simple -\end{code}+> main :: IO ()+> main = defaultMain
− Warning.hs
@@ -1,5 +0,0 @@-module Warning-  {-# WARNING ["You are configuring this package without cabal-doctest installed.",-               "The doctests test-suite will not work as a result.",-               "To fix this, install cabal-doctest before configuring."] #-}-  () where
approximate.cabal view
@@ -1,8 +1,8 @@ name:          approximate category:      Numeric-version:       0.3.1+version:       0.3.5 license:       BSD3-cabal-version: >= 1.8+cabal-version: >= 1.10 license-file:  LICENSE author:        Edward A. Kmett maintainer:    Edward A. Kmett <ekmett@gmail.com>@@ -10,60 +10,52 @@ homepage:      http://github.com/analytics/approximate/ bug-reports:   http://github.com/analytics/approximate/issues copyright:     Copyright (C) 2013 Edward A. Kmett-build-type:    Custom-tested-with:   GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2+build-type:    Simple+tested-with:   GHC == 8.0.2+             , GHC == 8.2.2+             , GHC == 8.4.4+             , GHC == 8.6.5+             , GHC == 8.8.4+             , GHC == 8.10.7+             , GHC == 9.0.1+             , GHC == 9.2.1 synopsis:      Approximate discrete values and numbers description:   This package provides approximate discrete values and numbers.  extra-source-files:-  .travis.yml   .ghci   .gitignore+  .hlint.yaml   .vim.custom-  travis/cabal-apt-install-  travis/config   AUTHORS.markdown   README.markdown   CHANGELOG.markdown-  HLint.hs-  Warning.hs -custom-setup-  setup-depends:-    base          >= 4.3 && <5,-    Cabal         >= 1.10,-    cabal-doctest >= 1 && <1.1- source-repository head   type: git   location: git://github.com/analytics/approximate.git --- You can disable the doctests test suite with -f-test-doctests-flag test-doctests-  default: True-  manual: True- flag herbie   default: False   manual: True  library   build-depends:-    base                      >= 4.3      && < 5,+    base                      >= 4.9      && < 5,     binary                    >= 0.5      && < 0.9,     bytes                     >= 0.7      && < 1,     cereal                    >= 0.3.5    && < 0.6,     comonad                   >= 3        && < 6,     deepseq                   >= 1.3      && < 1.5,     ghc-prim,-    hashable                  >= 1.2.5    && < 1.3,-    lens                      >= 3.9      && < 5,+    hashable                  >= 1.2.5    && < 1.5,+    lens                      >= 3.9      && < 6,     log-domain,     pointed                   >= 3        && < 6,     semigroupoids             >= 3.0.2    && < 6,     semigroups                >= 0.8.4    && < 1,-    safecopy                  >= 0.8.1    && < 0.10,-    vector                    >= 0.9      && < 0.13+    safecopy                  >= 0.8.1    && < 0.11,+    vector                    >= 0.12.1.2 && < 0.13    if flag(herbie)     build-depends: HerbiePlugin >= 0.1 && < 0.2@@ -76,27 +68,7 @@     Data.Approximate.Mass     Data.Approximate.Numerics -  if impl(ghc >= 7.4 && < 7.6)-    build-depends: ghc-prim-   c-sources: cbits/fast.c-  ghc-options: -Wall -fwarn-tabs -O2+  ghc-options: -Wall -Wtabs -O2   hs-source-dirs: src--test-suite doctests-  type:           exitcode-stdio-1.0-  main-is:        doctests.hs-  ghc-options:    -Wall -threaded-  hs-source-dirs: tests--  if !flag(test-doctests)-    buildable: False-  else-    build-depends:-      approximate,-      base,-      directory      >= 1.0,-      doctest        >= 0.9.1,-      filepath,-      semigroups     >= 0.9,-      simple-reflect >= 0.3.1+  default-language: Haskell2010
src/Data/Approximate/Mass.hs view
@@ -17,9 +17,6 @@   , (|?), (&?), (^?)   ) where -#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Control.Comonad import Control.DeepSeq import Control.Monad@@ -27,26 +24,27 @@ import Data.Bytes.Serial as Bytes import Data.Copointed import Data.Data-#if __GLASGOW_HASKELL__ < 710-import Data.Foldable-#endif import Data.Functor.Bind+import Data.Functor.Classes import Data.Functor.Extend import Data.Hashable (Hashable(..)) import Data.Hashable.Lifted (Hashable1(..)) import Data.Pointed import Data.SafeCopy+#if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup-import Data.Serialize as Serialize-#if __GLASGOW_HASKELL__ < 710-import Data.Traversable #endif-import Data.Vector.Generic as G-import Data.Vector.Generic.Mutable as M-import Data.Vector.Unboxed as U+import Data.Serialize as Serialize+import qualified Data.Vector.Generic as G+import qualified Data.Vector.Generic.Mutable as M+import qualified Data.Vector.Unboxed as U+import Data.Vector.Unboxed (Unbox) import GHC.Generics import Numeric.Log +-- $setup+-- >>> import Control.Monad (replicateM)+ -- | A quantity with a lower-bound on its probability mass. This represents -- a 'probable value' as a 'Monad' that you can use to calculate progressively -- less likely consequences.@@ -63,8 +61,13 @@ -- Also note that @('&?')@ and @('|?')@ are able to use knowledge about the -- function to get better precision on their results than naively using -- @'liftA2' ('&&')@+--+-- >>> let z = Mass 0.875 'z'+-- >>> replicateM 3 z+-- Mass 0.669921875 "zzz"+-- data Mass a = Mass {-# UNPACK #-} !(Log Double) a-  deriving (Eq,Ord,Show,Read,Typeable,Data,Generic)+  deriving (Eq,Ord,Show,Read,Data,Generic)  instance Binary a => Binary (Mass a) where   put (Mass p a) = Binary.put p >> Binary.put a@@ -74,8 +77,16 @@   put (Mass p a) = Serialize.put p >> Serialize.put a   get = Mass <$> Serialize.get <*> Serialize.get -instance Serialize a => SafeCopy (Mass a)+instance (Serialize a, Typeable a) => SafeCopy (Mass a) where+  -- safecopy-0.10.0 changed its default implementations for these methods.+  -- The implementations below are copied from the pre-0.10.0 defaults.+  errorTypeName _ = "<unknown type>"+  getCopy = contain Serialize.get+  putCopy = contain . Serialize.put +instance Eq1 Mass where+    liftEq eq (Mass p a) (Mass q b) = p == q && eq a b+ instance Hashable a => Hashable (Mass a) instance Hashable1 Mass where     liftHashWithSalt h s (Mass m x) = hashWithSalt s m `h` x@@ -124,10 +135,8 @@   {-# INLINE basicUnsafeMove #-}   basicUnsafeGrow (MV_Mass v) n = MV_Mass `liftM` M.basicUnsafeGrow v n   {-# INLINE basicUnsafeGrow #-}-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_Mass v) = M.basicInitialize v   {-# INLINE basicInitialize #-}-#endif  instance Unbox a => G.Vector U.Vector (Mass a) where   basicUnsafeFreeze (MV_Mass v) = V_Mass `liftM` G.basicUnsafeFreeze v@@ -177,8 +186,10 @@ instance Monoid a => Monoid (Mass a) where   mempty = Mass 1 mempty   {-# INLINE mempty #-}+#if !(MIN_VERSION_base(4,11,0))   mappend (Mass p a) (Mass q b) = Mass (p * q) (mappend a b)   {-# INLINE mappend #-}+#endif  instance Semigroup a => Semigroup (Mass a) where   Mass p a <> Mass q b = Mass (p * q) (a <> b)
src/Data/Approximate/Type.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TemplateHaskell #-}@@ -32,19 +30,18 @@ import Data.Bytes.Serial as Bytes import Data.Copointed import Data.Data-#if __GLASGOW_HASKELL__ < 710-import Data.Foldable-#endif import Data.Functor.Apply+import Data.Functor.Classes import Data.Hashable (Hashable(..)) import Data.Hashable.Lifted (Hashable1(..)) import Data.Monoid import Data.Pointed import Data.SafeCopy import Data.Serialize as Serialize-import Data.Vector.Generic as G-import Data.Vector.Generic.Mutable as M-import Data.Vector.Unboxed as U+import qualified Data.Vector.Generic as G+import qualified Data.Vector.Generic.Mutable as M+import qualified Data.Vector.Unboxed as U+import Data.Vector.Unboxed (Unbox) import GHC.Generics import Numeric.Log @@ -54,7 +51,7 @@ data Approximate a = Approximate   { _confidence :: {-# UNPACK #-} !(Log Double)   , _lo, _estimate, _hi :: a-  } deriving (Eq,Show,Read,Typeable,Data,Generic)+  } deriving (Eq,Show,Read,Data,Generic)  makeClassy ''Approximate @@ -66,8 +63,17 @@   put (Approximate p l m h) = Serialize.put p >> Serialize.put l >> Serialize.put m >> Serialize.put h   get = Approximate <$> Serialize.get <*> Serialize.get <*> Serialize.get <*> Serialize.get -instance Serialize a => SafeCopy (Approximate a)+instance (Serialize a, Typeable a) => SafeCopy (Approximate a) where+  -- safecopy-0.10.0 changed its default implementations for these methods.+  -- The implementations below are copied from the pre-0.10.0 defaults.+  errorTypeName _ = "<unknown type>"+  getCopy = contain Serialize.get+  putCopy = contain . Serialize.put +instance Eq1 Approximate where+    liftEq eq (Approximate p la ma ha) (Approximate q lb mb hb) =+      p == q && eq la lb && eq ma mb && eq ha hb+ instance Hashable a => Hashable (Approximate a) instance Hashable1 Approximate where     liftHashWithSalt h s (Approximate c low est high) =@@ -112,10 +118,8 @@   {-# INLINE basicUnsafeMove #-}   basicUnsafeGrow (MV_Approximate v) n = MV_Approximate `liftM` M.basicUnsafeGrow v n   {-# INLINE basicUnsafeGrow #-}-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_Approximate v) = M.basicInitialize v   {-# INLINE basicInitialize #-}-#endif  instance Unbox a => G.Vector U.Vector (Approximate a) where   basicUnsafeFreeze (MV_Approximate v) = V_Approximate `liftM` G.basicUnsafeFreeze v@@ -139,7 +143,7 @@   {-# INLINE elemseq #-}  instance NFData a => NFData (Approximate a) where-  rnf (Approximate _ l m h) = rnf l `seq` rnf m `seq` rnf h `seq` ()+  rnf (Approximate _ l m h) = rnf l `seq` rnf m `seq` rnf h  instance Functor Approximate where   fmap f (Approximate p l m h) = Approximate p (f l) (f m) (f h)
− tests/doctests.hs
@@ -1,25 +0,0 @@--------------------------------------------------------------------------------- |--- Module      :  Main (doctests)--- Copyright   :  (C) 2012-14 Edward Kmett--- License     :  BSD-style (see the file LICENSE)--- Maintainer  :  Edward Kmett <ekmett@gmail.com>--- Stability   :  provisional--- Portability :  portable------ This module provides doctests for a project based on the actual versions--- of the packages it was built with. It requires a corresponding Setup.lhs--- to be added to the project-------------------------------------------------------------------------------module Main where--import Build_doctests (flags, pkgs, module_sources)-import Data.Foldable (traverse_)-import Test.DocTest--main :: IO ()-main = do-    traverse_ putStrLn args-    doctest args-  where-    args = flags ++ pkgs ++ module_sources
− travis/cabal-apt-install
@@ -1,27 +0,0 @@-#! /bin/bash-set -eu--APT="sudo apt-get -q -y"-CABAL_INSTALL_DEPS="cabal install --only-dependencies --force-reinstall"--$APT update-$APT install dctrl-tools--# Find potential system packages to satisfy cabal dependencies-deps()-{-	local M='^\([^ ]\+\)-[0-9.]\+ (.*$'-	local G=' -o ( -FPackage -X libghc-\L\1\E-dev )'-	local E="$($CABAL_INSTALL_DEPS "$@" --dry-run -v 2> /dev/null \-		| sed -ne "s/$M/$G/p" | sort -u)"-	grep-aptavail -n -sPackage \( -FNone -X None \) $E | sort -u-}--$APT install $(deps "$@") libghc-quickcheck2-dev # QuickCheck is special-$CABAL_INSTALL_DEPS "$@" # Install the rest via Hackage--if ! $APT install hlint ; then-	$APT install $(deps hlint)-	cabal install hlint-fi-
− travis/config
@@ -1,16 +0,0 @@--- This provides a custom ~/.cabal/config file for use when hackage is down that should work on unix------ This is particularly useful for travis-ci to get it to stop complaining--- about a broken build when everything is still correct on our end.------ This uses Luite Stegeman's mirror of hackage provided by his 'hdiff' site instead------ To enable this, uncomment the before_script in .travis.yml--remote-repo: hdiff.luite.com:http://hdiff.luite.com/packages/archive-remote-repo-cache: ~/.cabal/packages-world-file: ~/.cabal/world-build-summary: ~/.cabal/logs/build.log-remote-build-reporting: anonymous-install-dirs user-install-dirs global