ekmett / keys

keyed functors
http://hackage.haskell.org/package/keys
Other
22 stars 13 forks source link

Add toKeyedNonEmptyList to FoldableWithKey1 type-class #23

Open recursion-ninja opened 5 years ago

recursion-ninja commented 5 years ago

The FoldableWithKey1 type-class needs a way to safely expose a NonEmpty of keyed associations whose implementation can also be overridden for efficiency.

I added the toKeyedNonEmptyList method to the type-class definition with a default implementation.

This new method is analogous to the toKeyedList method of the FoldableWithKey type-class.

RyanGlScott commented 1 year ago

Sorry it took me so long to review this! Indeed, if Foldable1 offers toNonEmpty, then it makes sense for FoldableWithKey1 to offer something similar.

One minor question about naming: how would you feel about naming the method toKeyedNonEmpty instead? That way, toKeyedList would be to toList as toKeyedNonEmpty would be to toNonEmpty in terms of naming conventions.