monadic map on a Data.IntMap

Hi, Is there something like a fmapM_ ? In particular, I'd like to mapM_ a Data.IntMap instead of a List Thank you, Thu

I suppose a
mapM_ monadicFunction . Data.IntMap.toList $ m
doesn't work for you?
On Mon, Sep 8, 2008 at 2:11 PM, minh thu
Hi,
Is there something like a fmapM_ ? In particular, I'd like to mapM_ a Data.IntMap instead of a List
Thank you, Thu _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards

2008/9/8 Jefferson Heard
I suppose a
mapM_ monadicFunction . Data.IntMap.toList $ m
doesn't work for you?
Well, that's what I use (IntMap.elems in fact), but isn't there some perfromance lost ? Thu
On Mon, Sep 8, 2008 at 2:11 PM, minh thu
wrote: Hi,
Is there something like a fmapM_ ? In particular, I'd like to mapM_ a Data.IntMap instead of a List
Thank you, Thu _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow.
-- Jessica Edwards

2008/9/8 minh thu
Hi,
Is there something like a fmapM_ ? In particular, I'd like to mapM_ a Data.IntMap instead of a List
The Traversable class (from Data.Traversable) includes a mapM function. Unfortunately Data.IntMap don't provide an instance for IntMap (though Data.Map does for Map). -- Jedaï

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
participants (4)
-
Chaddaï Fouché
-
Jefferson Heard
-
minh thu
-
Ross Paterson