edges 0.4.0.2 → 0.4.1
raw patch · 3 files changed
+37/−6 lines, 3 filesdep ~primitive-extrasPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: primitive-extras
API changes (from Hackage documentation)
+ Edges.Fold: edgeCounts :: Amount a -> Fold (Edge a b) (EdgeCounts a b)
+ Edges.Fold: edges :: EdgeCounts a b -> Amount b -> Fold (Edge a b) (Edges a b)
Files
- edges.cabal +3/−2
- library/Edges/Fold.hs +22/−0
- library/Edges/Types.hs +12/−4
edges.cabal view
@@ -1,7 +1,7 @@ name: edges version:- 0.4.0.2+ 0.4.1 category: Graphs synopsis:@@ -46,6 +46,7 @@ Edges.Node Edges.Potoki.Produce Edges.IO+ Edges.Fold other-modules: Edges.Cereal.Instances Edges.Cereal.Get@@ -63,7 +64,7 @@ potoki >=2.0.2 && <2.1, potoki-cereal >=0.3 && <0.4, primitive >=0.6.4 && <0.7,- primitive-extras >=0.6.1 && <0.7,+ primitive-extras >=0.6.2 && <0.7, profunctors >=5 && <6, QuickCheck >=2.8.1 && <3, semigroupoids >=5.2 && <6,
+ library/Edges/Fold.hs view
@@ -0,0 +1,22 @@+module Edges.Fold+where++import Edges.Prelude+import Edges.Types+import Edges.Node ()+import Edges.NodeCounts ()+import qualified PrimitiveExtras.PrimArray as PrimArray+import qualified PrimitiveExtras.PrimMultiArray as PrimMultiArray+++edgeCounts :: Amount a -> Fold (Edge a b) (EdgeCounts a b)+edgeCounts (Amount amountInt) =+ dimap edgeSourceIndex EdgeCounts (PrimArray.indexCountsFold amountInt)+ where+ edgeSourceIndex (Edge sourceIndex _) = sourceIndex++edges :: EdgeCounts a b -> Amount b -> Fold (Edge a b) (Edges a b)+edges (EdgeCounts edgeCountsPrimArray) (Amount bAmountInt) =+ dimap edgePair (Edges bAmountInt) (PrimMultiArray.fold edgeCountsPrimArray)+ where+ edgePair (Edge sourceIndex targetIndex) = (sourceIndex, targetIndex)
library/Edges/Types.hs view
@@ -1,14 +1,22 @@+{-# LANGUAGE StrictData #-}+{-# OPTIONS_GHC -funbox-strict-fields #-} module Edges.Types where import Edges.Prelude -data Edges source target =- Edges- {-# UNPACK #-} !Int {- Target array size -}- {-# UNPACK #-} !(PrimMultiArray Word32)+data Edges source target = Edges Int {- Target array size -} (PrimMultiArray Word32) newtype Node entity = Node Int newtype NodeCounts entity = NodeCounts (PrimArray Word32)++newtype EdgeCounts source target = EdgeCounts (PrimArray Word32)++data Edge source target = Edge Int Word32++{-|+Total amount of unique entities of the type+-}+newtype Amount entity = Amount Int