mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 18:29:36 +03:00
;lib: avoid nubSortBy which breaks ghc 7, 8.0 builds
This commit is contained in:
parent
23a7787ac4
commit
ec310aea73
@ -27,7 +27,7 @@ import Data.Decimal (roundTo)
|
|||||||
import Data.Function (on)
|
import Data.Function (on)
|
||||||
import Data.Graph.Inductive (Gr, Node, NodeMap, mkMapGraph, mkNode, lab, out, sp)
|
import Data.Graph.Inductive (Gr, Node, NodeMap, mkMapGraph, mkNode, lab, out, sp)
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.List.Extra
|
-- import Data.List.Extra (nubSortBy)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
@ -120,7 +120,9 @@ pricesAtDate pricedirectives d = PriceGraph{prGraph=g, prNodemap=m, prDeclaredPa
|
|||||||
-- get the latest (on or before date d) declared price for each commodity pair
|
-- get the latest (on or before date d) declared price for each commodity pair
|
||||||
declaredprices :: [MarketPrice] =
|
declaredprices :: [MarketPrice] =
|
||||||
dbg5 "declaredprices" $
|
dbg5 "declaredprices" $
|
||||||
nubSortBy (compare `on` (\(MarketPrice{..})->(mpfrom,mpto))) $ -- keep only the first (ie newest and latest parsed) price for each pair
|
-- 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
|
||||||
map snd $ -- discard the parse order label
|
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
|
sortBy (flip compare `on` (\(parseorder,mp)->(mpdate mp,parseorder))) $ -- sort with newest dates and latest parse order first
|
||||||
zip [1..] $ -- label with parse order
|
zip [1..] $ -- label with parse order
|
||||||
|
Loading…
Reference in New Issue
Block a user