[commit: base] master: Update comment on fmapDefault to note that it only works for Traversable instances with a given definition of traversable, and NOT for instances with only sequenceA given. (2c764e4)
Ian Lynagh
igloo at earth.li
Fri Apr 22 17:21:57 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/2c764e4266aedeea872abad159db0af62b0f26fb
>---------------------------------------------------------------
commit 2c764e4266aedeea872abad159db0af62b0f26fb
Author: Brent Yorgey <byorgey at LVN513-12.cis.upenn.edu>
Date: Fri Apr 15 15:22:54 2011 -0400
Update comment on fmapDefault to note that it only works for Traversable instances with a given definition of traversable, and NOT for instances with only sequenceA given.
>---------------------------------------------------------------
Data/Traversable.hs | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Data/Traversable.hs b/Data/Traversable.hs
index 2bdc1bc..062d1a0 100644
--- a/Data/Traversable.hs
+++ b/Data/Traversable.hs
@@ -170,7 +170,10 @@ instance Applicative (StateR s) where
mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)
mapAccumR f s t = runStateR (traverse (StateR . flip f) t) s
--- | This function may be used as a value for `fmap` in a `Functor` instance.
+-- | This function may be used as a value for `fmap` in a `Functor`
+-- instance, provided that 'traverse' is defined. (Using
+-- `fmapDefault` with a `Traversable` instance defined only by
+-- 'sequenceA' will result in infinite recursion.)
fmapDefault :: Traversable t => (a -> b) -> t a -> t b
{-# INLINE fmapDefault #-}
fmapDefault f = getId . traverse (Id . f)
More information about the Cvs-libraries
mailing list