[GHC] #8092: Map.unionWithMaybe
GHC
ghc-devs at haskell.org
Thu Jul 25 10:25:37 CEST 2013
#8092: Map.unionWithMaybe
-------------------------------------------+-------------------------------
Reporter: sjcjoosten | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 7.6.3
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Easy (less than 1 hour) | Type of failure:
Blocked By: | None/Unknown
Related Tickets: | Test Case:
| Blocking:
-------------------------------------------+-------------------------------
for Data.Map, I needed a "unionWithMaybe" function for my sparse system of
linear equations (unionWithMaybe :: Ord k => (a -> a -> Maybe a) -> Map k
a -> Map k a -> Map k a). My usage:
(.+.) = Map.unionWithMaybe (\a b->case a+b of {0->Nothing;s->Just s})
(I do not think Map.unionWithMaybe can be expressed in terms of other
functions without loosing performance, so I recon it would be a nice
addition to the library.)
I built this function myself by modifying the Data.Map implementation, but
it would be nice to see it in the official version of Data.Map.
Here is the file including the modifications I made to it. Feel free to
use it, I will agree to whatever license you need to make it public.
(PS: this is the first time I return modified source code to the
maintainer, feel free to instruct me on how to do this in the future.)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8092>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list