I have found from time to time, when using Data.Sequence, that a list-like
function that I expect to be there is in fact not present and its absence
is not mentioned; it always turns out to be implicit in one of Sequence's
instances. Examples: map, fold, (++). This is in principle no different,
except that MonadZip is apparently relatively obscure and, possibly, not
the "right" class according to Tony Morris' link.
I can't tell if this is an argument for or against the proposal, but it
does seem to reflect a choice to populate the Sequence API via
instantiating standard classes rather than writing standalone functions
(with possibly conflicting names, not that this is a new thing with these
container libraries). Both map and fold have Seq-specific indexed variants
that are *not* part of those classes, and if neatness is what the module
authors were going for, then this kind of variation is the only thing that
should actually appear in Data.Sequence itself. It does impact the
usefulness of the documentation, though. I think that's the real issue
here.
Post by Tikhon JelvisI did not know about MonadZip and wouldn't have thought to look for it.
On the other hand, unzip and unzipWith are immediately intuitive.
I think they'd be a solid addition.
Post by David FeuerWe don't strictly *need* to add either of these functions. Users can use
munzip from the MonadZip instance, and we can add a rewrite rule to turn
munzip (fmap f xs)
into
Data.Sequence.Internal.unzipWith f xs
On the other hand, MonadZip isn't a terribly well-known class, and
unzipWith has always struck me as an obvious analogue of zipWith.
On Jan 11, 2018 10:32 PM, "Ivan Lazar Miljenovic" <
Post by Ivan Lazar MiljenovicPost by David FeuerPaolo G. Giarrusso (Blaisorblade) would like to add an unzip function
to
Post by David FeuerData.Sequence. I agree. I propose adding
unzip :: Seq (a,b) -> (Seq a, Seq b)
unzipWith :: (x -> (a, b)) -> Seq x -> (Seq a, Seq b)
Does anyone object?
I see no problem with this. Though I think it's worth pointing out
that Data.List doesn't have unzipWith (though unzipWith f = unzip .
map f).
--
Ivan Lazar Miljenovic
http://IvanMiljenovic.wordpress.com
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries