IntMap intersectionWith type is too restrictive
Don Stewart
dons at galois.com
Fri May 16 14:07:28 EDT 2008
So a small issue is that we can't apply this patch. Sending
the full patch as an attachment is ok.
sedillard:
> [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
> >
More information about the Libraries
mailing list