16 May 20:03
Re: IntMap intersectionWith type is too restrictive
From: Scott Dillard <sedillard <at> ucdavis.edu>
Subject: Re: IntMap intersectionWith type is too restrictive
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2008-05-16 18:03:17 GMT
Subject: Re: IntMap intersectionWith type is too restrictive
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2008-05-16 18:03:17 GMT
[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
>
_______________________________________________ Libraries mailing list Libraries <at> haskell.org http://www.haskell.org/mailman/listinfo/libraries
RSS Feed