Frames-map-reduce 0.3.0.0 → 0.4.0.0
raw patch · 6 files changed
+66/−18 lines, 6 filesdep ~Framesdep ~basedep ~map-reduce-foldsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Frames, base, map-reduce-folds, random, vinyl
API changes (from Hackage documentation)
+ Frames.Folds: type ConstrainedFoldable c rs = (RPureConstrained (ConstrainedField c) rs, RPureConstrained KnownField rs, RApply rs, EndoFieldFoldsToRecordFolds rs)
+ Frames.MapReduce: splitOnData :: forall cs rs ks. (cs ⊆ rs, ks ~ RDeleteAll cs rs, ks ⊆ rs) => Assign (Record ks) (Record rs) (Record cs)
+ Frames.MapReduce.General: splitOnData :: forall cs rs ks record f. (RCastC ks rs record f, RCastC cs rs record f, ks ~ RDeleteAll cs rs) => Assign (record (f :. ElField) ks) (record (f :. ElField) rs) (record (f :. ElField) cs)
+ Frames.MapReduce.Maybe: splitOnData :: forall cs rs ks record. (RCastC ks rs record Maybe, RCastC cs rs record Maybe, ks ~ RDeleteAll cs rs) => Assign (record (Maybe :. ElField) ks) (record (Maybe :. ElField) rs) (record (Maybe :. ElField) cs)
- Frames.Folds: foldAllConstrained :: forall c rs. (RPureConstrained (ConstrainedField c) rs, RPureConstrained KnownField rs, RApply rs, EndoFieldFoldsToRecordFolds rs) => (forall a. c a => Fold a a) -> Fold (Record rs) (Record rs)
+ Frames.Folds: foldAllConstrained :: forall c rs. ConstrainedFoldable c rs => (forall a. c a => Fold a a) -> Fold (Record rs) (Record rs)
Files
- CHANGELOG.md +6/−0
- Frames-map-reduce.cabal +7/−7
- src/Frames/Folds.hs +17/−10
- src/Frames/MapReduce.hs +9/−1
- src/Frames/MapReduce/General.hs +12/−0
- src/Frames/MapReduce/Maybe.hs +15/−0
CHANGELOG.md view
@@ -1,3 +1,9 @@+v 0.4.0.0 +* Added ```splitOnData``` for assigning via a given set of data cols.+* Bumped upper bounds+* Checked compilation w/ghc-8.10.2+* Fixed a redundant include warning for Monoid using CPP in Frames.Folds+ v 0.3.0.0 * Added Combinator for aggregation in Frames.Aggregation along with helpers to create folds over data cols, promote simple functions to record functions to be used in aggregations, combine key aggregations.
Frames-map-reduce.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: Frames-map-reduce-version: 0.3.0.0+version: 0.4.0.0 synopsis: Frames wrapper for map-reduce-folds and some extra folds helpers. description: Frames-map-reduce provides some helpers for using the map-reduce-folds library with vinyl records and Frames. These include functions for filtering Frames, splitting records into key columns and data columns and@@ -17,7 +17,7 @@ category: Data extra-source-files: CHANGELOG.md Build-type: Simple-tested-with: GHC ==8.6.4 || ==8.6.2+tested-with: GHC ==8.6.5 || ==8.8.3 || ==8.10.2 source-repository head Type: git@@ -35,13 +35,13 @@ , Frames.Aggregation.General , Frames.Aggregation.Maybe - build-depends: Frames >= 0.6.1 && < 0.7,- base >= 4.12.0 && < 4.14,+ build-depends: Frames >= 0.6.1 && < 0.8,+ base >= 4.12.0 && < 4.15, containers >= 0.5.0 && < 0.7, hashable >= 1.2.7 && < 1.4,- map-reduce-folds >= 0.1.0.0 && < 0.1.0.5, + map-reduce-folds >= 0.1.0 && < 0.2, profunctors >= 5.3 && < 5.6,- vinyl >= 0.11.0 && < 0.13,+ vinyl >= 0.11.0 && < 0.14, foldl >= 1.4.5 && < 1.5, newtype >= 0.2 && < 0.3 hs-source-dirs: src@@ -60,5 +60,5 @@ text >= 1.2.3 && < 1.3, vector, vinyl,- random >= 1.1 && < 1.2, + random >= 1.2 && < 1.3, default-language: Haskell2010
src/Frames/Folds.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-}@@ -46,8 +47,9 @@ , sequenceRecFold , sequenceEndoFolds - -- * functions using constraints to extend an endo-fold across a record+ -- * functions/types using constraints to extend an endo-fold across a record , foldAll+ , ConstrainedFoldable , foldAllConstrained , foldAllMonoid @@ -59,9 +61,11 @@ import qualified Control.Foldl as FL import qualified Control.Newtype as N-import Data.Monoid ( (<>)- , Monoid(..)- )+#if MIN_VERSION_base(4,11,0)+#else +import Data.Monoid ( (<>) )+import Data.Monoid ( Monoid(..))+#endif import qualified Data.Profunctor as P import qualified Data.Vinyl as V import qualified Data.Vinyl.TypeLevel as V@@ -204,20 +208,23 @@ class (c (V.Snd t)) => ConstrainedField c t instance (c (V.Snd t)) => ConstrainedField c t +type ConstrainedFoldable c rs = (V.RPureConstrained (ConstrainedField c) rs+ , V.RPureConstrained V.KnownField rs+ , V.RApply rs+ , EndoFieldFoldsToRecordFolds rs+ )+ -- | Apply a constrained endo-fold to all fields of a record. -- May require a use of TypeApplications, e.g., foldAllConstrained @Num FL.sum foldAllConstrained- :: forall c rs- . ( V.RPureConstrained (ConstrainedField c) rs- , V.RPureConstrained V.KnownField rs- , V.RApply rs- , EndoFieldFoldsToRecordFolds rs- )+ :: forall c rs. ConstrainedFoldable c rs => (forall a . c a => FL.Fold a a) -> FL.Fold (F.Record rs) (F.Record rs) foldAllConstrained f = sequenceEndoFolds $ V.rpureConstrained @(ConstrainedField c) (FoldEndo f) {-# INLINABLE foldAllConstrained #-}++ -- | Given a monoid-wrapper, e.g., Sum, and functions to wrap and unwrap, we can produce an endo-fold on a monoidWrapperToFold
src/Frames/MapReduce.hs view
@@ -40,6 +40,7 @@ , assignKeysAndData , assignKeys , splitOnKeys+ , splitOnData -- * Reduce and Re-Attach Key Cols , reduceAndAddKey@@ -59,7 +60,6 @@ import qualified Control.Foldl as FL import qualified Data.Hashable as Hash-import Data.Hashable ( Hashable ) import qualified Frames as F import qualified Frames.Melt as F@@ -123,6 +123,14 @@ => MR.Assign (F.Record ks) (F.Record rs) (F.Record cs) splitOnKeys = assignKeysAndData @ks @cs {-# INLINABLE splitOnKeys #-}++-- | Assign data and leave the rest of the columns, excluding the data, as the key.+splitOnData+ :: forall cs rs ks+ . (cs F.⊆ rs, ks ~ F.RDeleteAll cs rs, ks F.⊆ rs)+ => MR.Assign (F.Record ks) (F.Record rs) (F.Record cs)+splitOnData = assignKeysAndData @ks @cs+{-# INLINABLE splitOnData #-} -- | Reduce the data to a single row and then re-attach the key. reduceAndAddKey
src/Frames/MapReduce/General.hs view
@@ -180,6 +180,18 @@ splitOnKeys = assignKeysAndData @ks @cs {-# INLINABLE splitOnKeys #-} +-- | Assign data and leave the rest of the columns, excluding the data, as the keys.+splitOnData+ :: forall cs rs ks record f+ . (RCastC ks rs record f, RCastC cs rs record f, ks ~ F.RDeleteAll cs rs)+ => MR.Assign+ (record (f :. ElField) ks)+ (record (f :. ElField) rs)+ (record (f :. ElField) cs)+splitOnData = assignKeysAndData @ks @cs+{-# INLINABLE splitOnData #-}++ -- | Assign keys and leave all columns, including the keys, in the data passed to reduce. assignKeys :: forall ks rs record f
src/Frames/MapReduce/Maybe.hs view
@@ -99,6 +99,21 @@ splitOnKeys = assignKeysAndData @ks @cs {-# INLINABLE splitOnKeys #-} +-- | Assign keys and leave the rest of the columns, excluding the keys, in the data passed to reduce.+splitOnData+ :: forall cs rs ks record+ . ( MG.RCastC ks rs record Maybe+ , MG.RCastC cs rs record Maybe+ , ks ~ F.RDeleteAll cs rs+ )+ => MR.Assign+ (record (Maybe :. ElField) ks)+ (record (Maybe :. ElField) rs)+ (record (Maybe :. ElField) cs)+splitOnData = assignKeysAndData @ks @cs+{-# INLINABLE splitOnData #-}++ -- | Assign keys and leave all columns, including the keys, in the data passed to reduce. assignKeys :: forall ks rs record