diff --git a/hledger/Hledger/Cli/Commands/Roi.hs b/hledger/Hledger/Cli/Commands/Roi.hs index 8266400d6..1ca1c53c6 100644 --- a/hledger/Hledger/Cli/Commands/Roi.hs +++ b/hledger/Hledger/Cli/Commands/Roi.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE QuasiQuotes,ParallelListComp #-} +{-# LANGUAGE QuasiQuotes,ParallelListComp,CPP #-} {-| The @roi@ command prints internal rate of return and time-weighted rate of return for and investment. @@ -17,7 +17,7 @@ import Text.Printf import Data.Function (on) import Data.List import Data.Ord -import Statistics.Math.RootFinding +import Numeric.RootFinding import Data.Decimal import Data.String.Here import System.Console.CmdArgs.Explicit as CmdArgs @@ -216,7 +216,13 @@ internalRateOfReturn showCashFlow prettyTables (OneSpan spanBegin spanEnd valueB (map ((:[]) . show) amounts)) -- 0% is always a solution, so require at least something here - case ridders 0.00001 (0.000000000001,10000) (interestSum spanEnd totalCF) of + case ridders +#if MIN_VERSION_math_functions(0,3,0) + (RiddersParam 100 (AbsTol 0.00001)) +#else + 0.00001 +#endif + (0.000000000001,10000) (interestSum spanEnd totalCF) of Root rate -> return ((rate-1)*100) NotBracketed -> error "Error: No solution -- not bracketed." SearchFailed -> error "Error: Failed to find solution." diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 17310eec8..34e9dfa3e 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 459ec44c2ae4fd1a0f7e0f8001c3efae2a39ff8b1ef53baa0a510b0674e98c2c +-- hash: 38ae7b05855ed1a89093bf46334c3ccd5d3e992499741befae04883a34da86b0 name: hledger version: 1.12 @@ -132,6 +132,7 @@ library , here , hledger-lib >=1.12 && <1.13 , lucid + , math-functions >=0.2.0.0 , megaparsec >=7.0.0 && <8 , mtl , mtl-compat @@ -143,7 +144,6 @@ library , safe >=0.2 , shakespeare >=2.0.2.2 , split >=0.1 - , statistics <=0.15 , tabular >=0.2 , temporary , text >=0.11 @@ -183,6 +183,7 @@ executable hledger , here , hledger , hledger-lib >=1.12 && <1.13 + , math-functions >=0.2.0.0 , megaparsec >=7.0.0 && <8 , mtl , mtl-compat @@ -194,7 +195,6 @@ executable hledger , safe >=0.2 , shakespeare >=2.0.2.2 , split >=0.1 - , statistics <=0.15 , tabular >=0.2 , temporary , text >=0.11 @@ -237,6 +237,7 @@ test-suite test , here , hledger , hledger-lib >=1.12 && <1.13 + , math-functions >=0.2.0.0 , megaparsec >=7.0.0 && <8 , mtl , mtl-compat @@ -248,7 +249,6 @@ test-suite test , safe >=0.2 , shakespeare >=2.0.2.2 , split >=0.1 - , statistics <=0.15 , tabular >=0.2 , temporary , test-framework @@ -292,6 +292,7 @@ benchmark bench , hledger , hledger-lib >=1.12 && <1.13 , html + , math-functions >=0.2.0.0 , megaparsec >=7.0.0 && <8 , mtl , mtl-compat @@ -303,7 +304,6 @@ benchmark bench , safe >=0.2 , shakespeare >=2.0.2.2 , split >=0.1 - , statistics <=0.15 , tabular >=0.2 , temporary , text >=0.11 diff --git a/hledger/package.yaml b/hledger/package.yaml index 156671600..285fd6c4f 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -104,7 +104,7 @@ dependencies: - safe >=0.2 - shakespeare >=2.0.2.2 - split >=0.1 -- statistics <=0.15 +- math-functions >=0.2.0.0 - tabular >=0.2 - temporary - text >=0.11 diff --git a/stack-ghc7.10.yaml b/stack-ghc7.10.yaml index 5e24a3363..c6d42ddbc 100644 --- a/stack-ghc7.10.yaml +++ b/stack-ghc7.10.yaml @@ -45,6 +45,7 @@ extra-deps: - integer-logarithms-1.0.2.1 - kan-extensions-5.1 - lens-4.16.1 +- math-functions-0.2.1.0 - megaparsec-7.0.1 - microstache-1.0.1.1 - mmorph-1.1.2 diff --git a/stack.yaml b/stack.yaml index b177546a6..51ee4ed75 100644 --- a/stack.yaml +++ b/stack.yaml @@ -24,7 +24,6 @@ extra-deps: # hledger - control-monad-free-0.6.2 -- statistics-0.14.0.2 - timeit-2.0 - wizards-1.0.3