Skip to content

Commit

Permalink
;deps: a better fix for nubSortBy with ghc 7.10, 8.0
Browse files Browse the repository at this point in the history
nubSortBy and nub . sortBy are not equivalent, it seems.
I didn't notice the failing valuation func tests.
  • Loading branch information
simonmichael committed Jul 13, 2019
1 parent 87ab586 commit 6f2f8d7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 2 additions & 4 deletions hledger-lib/Hledger/Data/Valuation.hs
Expand Up @@ -27,7 +27,7 @@ import Data.Decimal (roundTo)
import Data.Function (on)
import Data.Graph.Inductive (Gr, Node, NodeMap, mkMapGraph, mkNode, lab, out, sp)
import Data.List
-- import Data.List.Extra (nubSortBy)
import Data.List.Extra (nubSortBy)
import qualified Data.Map as M
import Data.Maybe
import qualified Data.Text as T
Expand Down Expand Up @@ -120,9 +120,7 @@ pricesAtDate pricedirectives d = PriceGraph{prGraph=g, prNodemap=m, prDeclaredPa
-- get the latest (on or before date d) declared price for each commodity pair
declaredprices :: [MarketPrice] =
dbg5 "declaredprices" $
-- XXX Data.List.Extra.nubSortBy might be more efficient (n Log n vs n^2 ?)
-- but is not in ghc 7.10, 8.0 stackage snapshots
nub $ sortBy (compare `on` (\(MarketPrice{..})->(mpfrom,mpto))) $ -- keep only the first (ie newest and latest parsed) price for each pair
nubSortBy (compare `on` (\(MarketPrice{..})->(mpfrom,mpto))) $ -- keep only the first (ie newest and latest parsed) price for each pair
map snd $ -- discard the parse order label
sortBy (flip compare `on` (\(parseorder,mp)->(mpdate mp,parseorder))) $ -- sort with newest dates and latest parse order first
zip [1..] $ -- label with parse order
Expand Down
8 changes: 4 additions & 4 deletions hledger-lib/hledger-lib.cabal
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 940be6dde18cf33cca2096d9176100b9ba178418eea2f1427d94fc5ffe58e783
-- hash: 4cfc4e9879ec711800e91c2cfe108a99c36d80ccb81b59e1df314915e94d5523

name: hledger-lib
version: 1.14.99
Expand Down Expand Up @@ -120,7 +120,7 @@ library
, deepseq
, directory
, easytest >=0.2.1 && <0.3
, extra
, extra >=1.6.3
, fgl >=5.5.4.0
, file-embed >=0.0.10
, filepath
Expand Down Expand Up @@ -223,7 +223,7 @@ test-suite doctests
, directory
, doctest >=0.16
, easytest >=0.2.1 && <0.3
, extra
, extra >=1.6.3
, fgl >=5.5.4.0
, file-embed >=0.0.10
, filepath
Expand Down Expand Up @@ -325,7 +325,7 @@ test-suite easytests
, deepseq
, directory
, easytest >=0.2.1 && <0.3
, extra
, extra >=1.6.3
, fgl >=5.5.4.0
, file-embed >=0.0.10
, filepath
Expand Down
2 changes: 1 addition & 1 deletion hledger-lib/package.yaml
Expand Up @@ -76,7 +76,7 @@ dependencies:
- transformers >=0.2
- uglymemo
- utf8-string >=0.3.5
- extra
- extra >=1.6.3
- Glob >= 0.9
# for ledger-parse:
#- parsers >=0.5
Expand Down
1 change: 1 addition & 0 deletions stack-ghc7.10.yaml
Expand Up @@ -35,6 +35,7 @@ extra-deps:
- directory-1.2.7.0
- doctest-0.16.0
- exceptions-0.10.0
- extra-1.6.17
- fgl-5.5.4.0
- free-5.0.2
- generics-sop-0.3.2.0
Expand Down
1 change: 1 addition & 0 deletions stack-ghc8.0.yaml
Expand Up @@ -24,6 +24,7 @@ extra-deps:
- config-ini-0.2.3.0
- criterion-1.4.1.0
- doctest-0.16.0
- extra-1.6.17
- fgl-5.5.4.0
- generics-sop-0.3.2.0
- hashable-1.2.7.0
Expand Down

0 comments on commit 6f2f8d7

Please sign in to comment.