[Haskell-cafe] monadic map on a Data.IntMap

Ross Paterson ross at soi.city.ac.uk
Mon Sep 8 18:02:40 EDT 2008

On Mon, Sep 08, 2008 at 08:56:26PM +0200, Chaddaï Fouché wrote:
> Unfortunately Data.IntMap don't provide an instance for IntMap (though
> Data.Map does for Map).

It was an oversight.  The instance is straightforward:

instance Traversable IntMap where
    traverse _ Nil = pure Nil
    traverse f (Tip k v) = Tip k <$> f v
    traverse f (Bin p m l r) = Bin p m <$> traverse f l <*> traverse f r

More information about the Haskell-Cafe mailing list