[Haskell-cafe] Generalizing unionWithKey, unionWith, ...

Petr Pudlák petr.mvd at gmail.com
Tue May 28 17:02:23 CEST 2013


Dne 28.5.2013 12:32, Johannes Waldmann napsal(a):
> Jose A. Lopes <jose.lopes <at> ist.utl.pt> writes:
>
>>      unionWith :: Ord k => (a -> b -> c) -> Map k a -> Map
>>      k b -> Map k c
> what should be the result of
>
> unionWith undefined (M.singleton False 42) (M.singleton True "bar")  ?
Perhaps the generalized signature should be instead:

```haskell
unionWith :: Ord k => (Maybe a -> Maybe b -> c) -> Map k a -> Map k b -> 
Map k c
```
(The function would always get at least one `Just`.)
But this functionality can be achieved using `map`s and the current 
`unionWith`.

P.P.



More information about the Haskell-Cafe mailing list