projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
57b9366
)
Update comment on fmapDefault to note that it only works for Traversable instances...
author
Brent Yorgey
<byorgey@LVN513-12.cis.upenn.edu>
Fri, 15 Apr 2011 19:22:54 +0000
(15:22 -0400)
committer
Ian Lynagh
<igloo@earth.li>
Fri, 22 Apr 2011 13:46:47 +0000
(14:46 +0100)
Data/Traversable.hs
patch
|
blob
|
history
diff --git
a/Data/Traversable.hs
b/Data/Traversable.hs
index
2bdc1bc
..
062d1a0
100644
(file)
--- 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
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)
fmapDefault :: Traversable t => (a -> b) -> t a -> t b
{-# INLINE fmapDefault #-}
fmapDefault f = getId . traverse (Id . f)