Ticket #5124: 0001-Update-comment-on-fmapDefault-to-note-that-it-only-w.patch

File 0001-Update-comment-on-fmapDefault-to-note-that-it-only-w.patch, 1.2 KB (added by byorgey, 2 years ago)
  • Data/Traversable.hs

    From 588ddc7a3400d4462253fbc13a2ccb211aa6a00e Mon Sep 17 00:00:00 2001
    From: Brent Yorgey <byorgey@LVN513-12.cis.upenn.edu>
    Date: Fri, 15 Apr 2011 15:22:54 -0400
    Subject: [PATCH] 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 b  
    170170mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c) 
    171171mapAccumR f s t = runStateR (traverse (StateR . flip f) t) s 
    172172 
    173 -- | This function may be used as a value for `fmap` in a `Functor` instance. 
     173-- | This function may be used as a value for `fmap` in a `Functor` 
     174--   instance, provided that 'traverse' is defined. (Using 
     175--   `fmapDefault` with a `Traversable` instance defined only by 
     176--   'sequenceA' will result in infinite recursion.) 
    174177fmapDefault :: Traversable t => (a -> b) -> t a -> t b 
    175178{-# INLINE fmapDefault #-} 
    176179fmapDefault f = getId . traverse (Id . f)