adamconnersax / frames-map-reduce Goto Github PK
View Code? Open in Web Editor NEWmap-reduce-folds helpers for use with Frames
License: BSD 3-Clause "New" or "Revised" License
map-reduce-folds helpers for use with Frames
License: BSD 3-Clause "New" or "Revised" License
I took an exploratory stab at trying to make some of the combinators in this library polymorphic in the interpretation functor and quickly ran up against the limits of its design. I imagine it's not straightforward (having run into similar difficulties myself) to to express folds over records where data may be missing.
Have you given such an implementation any thought?
The expected functionality, I think, would be something like:
a
, use the composite Maybe a
for grouping.as
, if there's Nothing
, then there's no step, otherwise take the data and step.The two sources of difficulty in my mind are constraining the payload through the composed functors and, at the same time, running the fold on the undistributed
version of the data.
(Separately, it'd also be nice to be able to support ARec
s as well.)
cc: @o1lo01ol1o
I finished rounding out the Maybe stuff you did in #2. It's in the latest commit on master. I did the minimum required to restore all the functions that were already there in the non-Maybe version. I added
rgetMaybeField
:: forall t rs
. (V.KnownField t, F.ElemOf rs t, V.FieldType (V.Fst t) rs ~ V.Snd t)
=> F.Rec (Maybe :. ElField) rs
-> Maybe (V.Snd t)
rgetMaybeField = fmap V.getField . V.getCompose . V.rgetf (V.Label @(V.Fst t))
and
-- | Control.Foldl helper for filtering Nothings
maybeFold :: FL.Fold a b -> FL.Fold (Maybe a) b
maybeFold (FL.Fold step begin done) = FL.Fold step' begin done
where step' x ma = maybe x (step x) ma
to help and to point the way to generalization.
and made your foldAllConstrained
into maybeFoldAllConstrained
so that I could re-use foldAllConstrained
for the case when the input fold is Fold a a
which is then generalized to Fold (Maybe a) (Maybe a)
via fmap Just . maybeFold
If you have a chance to take a look, that would be great.
Now I'm going to make a branch to try and generalize it all, including the record-type. If that works, I'll try to re-express these as monomorphizations (is that a word??) of the general thing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.