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

#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

#13058: Use coercions to implement fmapDefault and foldMapDefault -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Sounds reasonable to me. We already have most of the machinery needed to do this, since `(#.)` is [http://git.haskell.org/ghc.git/blob/8d63ca981f689463655766c252160d3fec160264... already used in base], located within the internal `Data.Functor.Utils` module. David, would you care to add `(.#)` as well and refactor `fmapDefault` and `foldMapDefault` as you propose? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13058#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13058: Use coercions to implement fmapDefault and foldMapDefault -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * owner: => dfeuer -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13058#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13058: Use coercions to implement fmapDefault and foldMapDefault -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett): Sounds good to me. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13058#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13058: Use coercions to implement fmapDefault and foldMapDefault -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: task | Status: patch Priority: normal | Milestone: 8.2.1 Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab: D2916 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: new => patch * differential: => Phab: D2916 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13058#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13058: Use coercions to implement fmapDefault and foldMapDefault -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: task | Status: patch Priority: normal | Milestone: 8.2.1 Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2916 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * differential: Phab: D2916 => Phab:D2916 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13058#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13058: Use coercions to implement fmapDefault and foldMapDefault
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: dfeuer
Type: task | Status: patch
Priority: normal | Milestone: 8.2.1
Component: Core Libraries | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2916
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#13058: Use coercions to implement fmapDefault and foldMapDefault -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dfeuer Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Core Libraries | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2916 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13058#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC