[GHC] #13058: Use coercions to implement fmapDefault and foldMapDefault

GHC ghc-devs at haskell.org
Tue Jan 3 03:49:18 UTC 2017


#13058: Use coercions to implement fmapDefault and foldMapDefault
-------------------------------------+-------------------------------------
           Reporter:  dfeuer         |             Owner:
               Type:  task           |            Status:  new
           Priority:  normal         |         Milestone:  8.2.1
          Component:  Core           |           Version:  8.0.1
  Libraries                          |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 We should be able to use

 {{{#!hs
 fmapDefault :: Traversable t => (a -> b) -> t a -> t b
 fmapDefault = (getId .) #. traverse .# (Id .)

 foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m
 foldMapDefault = (getConst .) #. traverse .# (Const .)
 }}}

 where `.#` and `#.` are coercion operators found in
 `Data.Profunctor.Unsafe`. This should help when the function passed in
 doesn't inline.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13058>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list