[GHC] #8347: Add a Strict LANGUAGE pragma
#8347: Add a Strict LANGUAGE pragma ------------------------------------+------------------------------------- Reporter: tibbe | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- A `Strict` `LANGUAGE` pragma would allow us to experiment with writing in a strict sub-language. Since this pragma works on a per module basis, it needs to be modular. I propose the following semantics: * Patterns are strict at the top-level, as if they had a top-level bang, unless an explicit ~ is used to make the pattern lazy. * Functions evaluate their parameters to WHNF. * Data type fields are strict (as if they had a bang-pattern). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------ Reporter: tibbe | Owner: tibbe Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by tibbe): * owner: => tibbe -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: tibbe Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.6.3 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: tibbe Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D1033 -------------------------------------+------------------------------------- Changes (by thomie): * differential: => Phab:D1033 * milestone: => 7.12.1 Comment: From https://ghc.haskell.org/trac/ghc/wiki/StrictPragma:
Haskell doesn't allow for ~ patterns in data constructor definitions today: we'll add support for such definitions and have it give the current lazy behavior.
From Phab:D1033, I understand that using `~` in data constructor definitions without `-XStrictData` will be the error: "Lazy annotation (~) without StrictData" Maybe it would be useful to be able to compile a module both with and without `-XStrictData`, to compare performance differences. In that case this new `~` syntax should be under a different language pragma. Has this been given consideration? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: tibbe Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D1033 -------------------------------------+------------------------------------- Comment (by tibbe): I would pile on even more stuff on Phab:D1033, but we could add a `-XExplicitLazyFields` language pragma that's implied by `-XStrictFields` in a separate commit. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: tibbe Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1033 -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"f842ad6c751c14ec331ca1709538c2f3e9a30ae7/ghc" f842ad6/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="f842ad6c751c14ec331ca1709538c2f3e9a30ae7" Implementation of StrictData language extension This implements the `StrictData` language extension, which lets the programmer default to strict data fields in datatype declarations on a per-module basis. Specification and motivation can be found at https://ghc.haskell.org/trac/ghc/wiki/StrictPragma This includes a tricky parser change due to conflicts regarding `~` in the type level syntax: all ~'s are parsed as strictness annotations (see `strict_mark` in Parser.y) and then turned into equality constraints at the appropriate places using `RdrHsSyn.splitTilde`. Updates haddock submodule. Test Plan: Validate through Harbormaster. Reviewers: goldfire, austin, hvr, simonpj, tibbe, bgamari Reviewed By: simonpj, tibbe, bgamari Subscribers: lelf, simonpj, alanz, goldfire, thomie, bgamari, mpickering Differential Revision: https://phabricator.haskell.org/D1033 GHC Trac Issues: #8347 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: | Phab:D1033, Phab:D1142 -------------------------------------+------------------------------------- Changes (by adamse): * owner: tibbe => adamse * differential: Phab:D1033 => Phab:D1033, Phab:D1142 Old description:
A `Strict` `LANGUAGE` pragma would allow us to experiment with writing in a strict sub-language. Since this pragma works on a per module basis, it needs to be modular. I propose the following semantics:
* Patterns are strict at the top-level, as if they had a top-level bang, unless an explicit ~ is used to make the pattern lazy. * Functions evaluate their parameters to WHNF. * Data type fields are strict (as if they had a bang-pattern).
New description: A `Strict` `LANGUAGE` pragma would allow us to experiment with writing in a strict sub-language. Since this pragma works on a per module basis, it needs to be modular. I propose the following semantics: * Patterns are strict at the top-level, as if they had a top-level bang, unless an explicit ~ is used to make the pattern lazy. * Functions evaluate their parameters to WHNF. * Data type fields are strict (as if they had a bang-pattern). Design page: StrictPragma -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: | Phab:D1033, Phab:D1142 -------------------------------------+------------------------------------- Changes (by simonpj): * cc: adamse, tibbe (added) Comment: If this is committed, can we close it? However, I wish there were a few regression tests to demonstrate the feature. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: | Phab:D1033, Phab:D1142 -------------------------------------+------------------------------------- Comment (by tibbe): Only the `StrictData` part is done. The more general `Strict` pragma (i.e. also dealing with bindings) is still waiting for review (https://phabricator.haskell.org/D1142). If you haven't taken a look already, please do so. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: | Phab:D1033, Phab:D1142 -------------------------------------+------------------------------------- Comment (by simonpj): OK I'll do that. Still, regression tests for the `StrictData` part would be good. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: | Phab:D1033, Phab:D1142 -------------------------------------+------------------------------------- Comment (by adamse): See https://ghc.haskell.org/trac/ghc/browser/ghc/testsuite/tests/deSugar/should_... for regression tests for `StrictData`. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | DsStrictData Blocked By: | Blocking: Related Tickets: | Differential Revisions: | Phab:D1033, Phab:D1142 -------------------------------------+------------------------------------- Changes (by adamse): * testcase: => DsStrictData -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | DsStrictData Blocked By: | Blocking: Related Tickets: | Differential Revisions: | Phab:D1033, Phab:D1142 -------------------------------------+------------------------------------- Comment (by simonpj): Sorry, missed that test. Good! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: DsStrictData Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1033, | Phab:D1142 -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"46a03fbec6a02761db079d1746532565f34c340f/ghc" 46a03fb/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="46a03fbec6a02761db079d1746532565f34c340f" Implement the Strict language extension Add a new language extension `-XStrict` which turns all bindings strict as if the programmer had written a `!` before it. This also upgrades ordinary Haskell to allow recursive and polymorphic strict bindings. See the wiki[1] and the Note [Desugar Strict binds] in DsBinds for specification and implementation details. [1] https://ghc.haskell.org/trac/ghc/wiki/StrictPragma Reviewers: austin, tibbe, simonpj, bgamari Reviewed By: tibbe, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1142 GHC Trac Issues: #8347 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8347: Add a Strict LANGUAGE pragma -------------------------------------+------------------------------------- Reporter: tibbe | Owner: adamse Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: DsStrictData, | DsStrictLet, DsStrictFail, | DsStrictWarn Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1033, Wiki Page: | Phab:D1142 -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * testcase: DsStrictData => DsStrictData, DsStrictLet, DsStrictFail, DsStrictWarn * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8347#comment:15> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC