IntMap intersectionWith type is too restrictive
Scott Dillard
sedillard at ucdavis.edu
Fri May 16 14:03:17 EDT 2008
[generalized type of IntMap.intersectionWith(Key)
sedillard at gmail.com**20080516174305
This patch brings the type of IntMap.intersectionWith(Key) in line with that of
Map.intersectionWith(Key).
was :: (a->b->a) -> IntMap a -> IntMap b -> IntMap a
now :: (a->b->c) -> IntMap a -> IntMap b -> IntMap c
I don't have the test suite but it works fine in GHCi
*Data.IntMap> intersectionWith (,) (fromList $ zip [1..3] ['a'..'c'])
(fromList $ zip [1..3] ['A'..'C'])
fromList [(1,('a','A')),(2,('b','B')),(3,('c','C'))]
] {
hunk ./Data/IntMap.hs 795
-intersectionWith :: (a -> b -> a) -> IntMap a -> IntMap b -> IntMap a
+intersectionWith :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
hunk ./Data/IntMap.hs 804
-intersectionWithKey :: (Key -> a -> b -> a) -> IntMap a -> IntMap b -> IntMap a
+intersectionWithKey :: (Key -> a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
}
Context:
The rest of the 67K is context :)
On Fri, May 16, 2008 at 11:28 AM, Don Stewart <dons at galois.com> wrote:
> sedillard:
>> Hi,
>>
>> This is a simple bug report, more or less. The type of
>> Data.IntMap.intersectionWith is too restrictive. Presently (GHC 8.2,
>> http://darcs.haskell.org/packages/containers/Data/) it's declared as
>> (a->b->a) -> IntMap a -> IntMap b -> IntMap a, but if you just remove
>> the type declarations it's inferred as (a->b->c) -> IntMap a -> IntMap
>> b -> IntMap c. Similarly for intersectionWithKey. The more general
>> a->b->c type is also the type of Data.Map.intersectionWith, and it's
>> quite useful, such as (intersectionWith (,))
>
> Can you submit a patch? This kind of thing comes up occasionally,
> and generalising the type is often safe and easy.
>
> -- Don
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: application/octet-stream
Size: 67768 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/libraries/attachments/20080516/869ad6d1/patch-0001.obj
More information about the Libraries
mailing list