[GHC] #12178: Allow inline pragmas on pattern synonyms

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple PatternSynonyms | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Richard observes that it might be useful to allow inline pragmas to refer to pattern synonyms to ensure that the matcher is inlined. The main question to resolve is whether `{-# INLINE P #-}` means to inline just the matcher, just the builder or both. It seems that without more fine grained control then the pragma should cause both the matcher and builder to be inline but I am not certain about this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms 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 edsko): * cc: edsko (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: feature request | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms 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 bgamari): * priority: normal => high * cc: bgamari (added) Comment: Bumping the importance of this since you really should be able to use pattern synonyms in a manner without compromising performance. I agree that a simple `INLINE P` pragma should inline both the matcher and the builder. Indeed we could expose `INLINE_MATCHER` and `INLINE_BUILDER` variants as well, although I am doubtful that they would pull their weight. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: feature request | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms 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 goldfire): I hate to say it, but I feel confident someone will want the finer control here. But I suppose there would be no barrier to implementing the finer control later and so we should start with the simpler version. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: feature request | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms 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 bgamari): * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature request | Status: new Priority: high | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms 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 bgamari): * milestone: 8.2.1 => 8.4.1 Comment: Sadly yhis won't happen for 8.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: osa1 Type: feature request | Status: new Priority: high | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms 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 osa1): * owner: (none) => osa1 Comment: I have some time to work on GHC these days and I'll be working on this feature. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: osa1 Type: feature request | Status: new Priority: high | Milestone: 8.6.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms, newcomer 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 bgamari): * keywords: PatternSynonyms => PatternSynonyms, newcomer * milestone: 8.4.1 => 8.6.1 Comment: Perhaps we'll be able to get this done for 8.6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: osa1 Type: feature request | Status: new Priority: high | Milestone: 8.8.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms, newcomer 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 bgamari): * milestone: 8.6.1 => 8.8.1 Comment: This won't happen for 8.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature request | Status: new Priority: high | Milestone: 8.8.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms, newcomer 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 osa1): * owner: osa1 => (none) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature request | Status: new Priority: high | Milestone: 8.8.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms, newcomer 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 chessai): Why would a pattern synonym not get inlined by default, always? Pattern Synonyms AFAIK don't perform any computation; only computation that may occur within a Pattern Synonym would be within ViewPatterns, but inlining any function inside of the ViewPattern shouldn't matter to just the issue of inlining the Pattern Synonym. Please correct me if I am wrong or missing something. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12178: Allow inline pragmas on pattern synonyms -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature request | Status: new Priority: high | Milestone: 8.8.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms, newcomer 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 simonpj):
Why would a pattern synonym not get inlined by default, always?
The only disadvantage to inlining is code size; and that applies equally to all inlining decisions, whether for pattern synonyms or any other function. Consider {{{ pattern P a = [[[[a]]]] f x = P (x+1) g y = P (y-1) }}} Here's what it compiles to, without inlining {{{ $bP x = (:) ((:) ((:) ((:) x []) []) []) [] f x = $bP (x+1) g y = $bP (y-1) }}} Yes, we could inline `$bP`: {{{ f x = (:) ((:) ((:) ((:) (x+1) []) []) []) [] g y = (:) ((:) ((:) ((:) (y-1) []) []) []) [] }}} But really nothing much was gained by inlining the builder `$bp`. It's the same for matching. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12178#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC