containers-backpack icon indicating copy to clipboard operation
containers-backpack copied to clipboard

Add default implementations of some functions

Open chshersh opened this issue 7 years ago • 3 comments

These functions can be put directly to containers-sig-* packages.

  • !? as an operator version of lookup
  • // for Map difference

For example, there's this useful operator:

infixl 9 !?
(!?) :: Key k => Map k v -> k -> Maybe v
(!?) m k = lookup k m

And probably there exist other useful functions with default implementations. We need to collect such functions and put them near signatures. Though, good naming for module is most difficult part here...

chshersh avatar Sep 04 '18 16:09 chshersh

Hi! I would like to grab this issue.

wisn avatar Oct 02 '18 01:10 wisn

@wisn Go for it!

chshersh avatar Oct 02 '18 04:10 chshersh

@wisn If you're going to do this issue. let's also do one more thing: let's remove lookupDefault function from signature and every instance and add default implementation using lookup and fromMaybe. I think that it doesn't make much sense to put this function into signatures, it's enough to have default implementation that automatically works for every data type. You can even rename it to lookupDef if you prefer shorter name :slightly_smiling_face:

chshersh avatar Oct 06 '18 08:10 chshersh