[GHC] #9540: unwords is not a good producer

#9540: unwords is not a good producer -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Keywords: fusion | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 | Type of failure: Runtime hour) | performance bug Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- I think we can do something like this, once we've fixed `unfoldr`: {{{#!hs unwords = unfoldr go where go [] = Nothing go ("":ws) = Just (' ', ws) go ((l:ls):ws) = Just (l, ls:ws) }}} With my draft `unfoldr`, GHC turns this into {{{#!hs lvl_r1EN lvl_r1EN = C# ' ' Rec { unwords_$sgo unwords_$sgo = \ sc_s1Gx sc1_s1Gy -> case sc_s1Gx of _ { [] -> : lvl_r1EN (unwords_go sc1_s1Gy); : l_a1Ew ls_a1Ex -> : l_a1Ew (unwords_$sgo ls_a1Ex sc1_s1Gy) } unwords_go unwords_go = \ b1_a1Fb -> case b1_a1Fb of _ { [] -> []; : ds_d1F5 ws_a1Ev -> case ds_d1F5 of _ { [] -> : lvl_r1EN (unwords_go ws_a1Ev); : l_a1Ew ls_a1Ex -> : l_a1Ew (unwords_$sgo ls_a1Ex ws_a1Ev) } } end Rec } unwords unwords = \ b'_a1F9 -> unwords_go b'_a1F9 }}} To my untrained eye, that looks pretty reasonable. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9540 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9540: words is not a good producer; unwords is not a good consumer -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 Resolution: | Keywords: fusion Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: Runtime | hour) performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: D375 | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: new => patch * differential: => D375 * milestone: => 7.10.1 Comment: I've changed my mind; I think it probably (but not necessarily) makes more sense to make `unwords` be a good consumer and `words` a good producer, so they can play nice with each other. If I could make `unwords` both, that'd be the ideal, but we can at least go one way. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9540#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9540: words is not a good producer; unwords is not a good consumer -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: patch Priority: normal | Milestone: 7.10.1 Component: Core | Version: 7.9 Libraries | Keywords: fusion Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: Runtime | Blocked By: performance bug | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D375 | -------------------------------------+------------------------------------- Changes (by thomie): * cc: core-libraries-committee@… (added) * differential: D375 => Phab:D375 * component: Compiler => Core Libraries -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9540#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9540: words is not a good producer; unwords is not a good consumer -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Core | Version: 7.9 Libraries | Keywords: fusion Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: Runtime | Blocked By: performance bug | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D375 | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: patch => closed * resolution: => fixed Comment: This was merged: https://phabricator.haskell.org/rGHCe73ab5412935392c03ce736ebee2b1282932c2ff (or just e73ab5412935392c03ce736ebee2b1282932c2ff) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9540#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC