[GHC] #9654: Clean up stringify in util/hsc2hs/CrossCodegen
 
            #9654: Clean up stringify in util/hsc2hs/CrossCodegen -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: task | Status: new Priority: normal | Milestone: 7.10.1 Component: Code Coverage | Version: 7.9 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 | Type of failure: hour) | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Currently, it's defined {{{#!hs stringify :: String -> String stringify s = reverse . dropWhile isSpace . reverse -- drop trailing space . dropWhile isSpace -- drop leading space . compressSpaces -- replace each span of -- whitespace with a single space $ s where compressSpaces [] = [] compressSpaces (a:as) | isSpace a = ' ' : compressSpaces (dropWhile isSpace as) compressSpaces (a:as) = a : compressSpaces as }}} If we're going to go to the trouble of doing this by hand, we might as well take the efficiency advantage doing so can give us: {{{#!hs stringify :: String -> String -- Spec: stringify = unwords . words stringify xs = go False (dropWhile isSpace xs) where go _haveSpace [] = [] go haveSpace (x:xs) | isSpace x = go True xs | otherwise = if haveSpace then ' ' : x : go False xs else x : go False xs }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9654 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
 
            #9654: Clean up stringify in util/hsc2hs/CrossCodegen -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: task | Status: patch Priority: normal | Milestone: 7.10.1 Component: Code | Version: 7.9 Coverage | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9654#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
 
            #9654: Clean up stringify in util/hsc2hs/CrossCodegen -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: task | Status: patch Priority: normal | Milestone: 7.10.1 Component: hsc2hs | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: | hour) None/Unknown | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by dfeuer): * component: Code Coverage => hsc2hs -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9654#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
 
            #9654: Clean up stringify in util/hsc2hs/CrossCodegen -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: task | Status: patch Priority: normal | Milestone: 7.10.1 Component: hsc2hs | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: | hour) None/Unknown | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by nomeata): Applied, pending validation. The code was not `-Werror`-safe; it would be nice if submitted patches were validated (or, if not, that fact were mentioned when submitting). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9654#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
 
            #9654: Clean up stringify in util/hsc2hs/CrossCodegen
-------------------------------------+-------------------------------------
              Reporter:  dfeuer      |            Owner:
                  Type:  task        |           Status:  patch
              Priority:  normal      |        Milestone:  7.10.1
             Component:  hsc2hs      |          Version:  7.9
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Easy (less than 1
       Type of failure:              |  hour)
  None/Unknown                       |       Blocked By:
             Test Case:              |  Related Tickets:
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
Comment (by Joachim Breitner 
 
            #9654: Clean up stringify in util/hsc2hs/CrossCodegen -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: task | Status: closed Priority: normal | Milestone: 7.10.1 Component: hsc2hs | Version: 7.9 Resolution: fixed | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Easy (less than 1 Type of failure: | hour) None/Unknown | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by nomeata): * status: patch => closed * resolution: => fixed Comment: Thanks for your contribution! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9654#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
- 
                 GHC GHC