diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2016-02-25 15:53:03 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2016-02-26 17:14:59 +0000 |
commit | e3f341f334d89c88f388d8e864ed8762d0890a64 (patch) | |
tree | cbf769fab5ae1eb54324b33ec10b554488458b7b /libraries/ghc-prim | |
parent | a02611210b9846ee18de179c932915a838fdacb5 (diff) | |
download | haskell-e3f341f334d89c88f388d8e864ed8762d0890a64.tar.gz |
Fix and refactor strict pattern bindings
This patch was triggered by Trac #11601, where I discovered that
-XStrict was really not doing the right thing. In particular,
f y = let !(Just x) = blah[y] in body[y,x]
This was evaluating 'blah' but not pattern matching it
against Just until x was demanded. This is wrong.
The patch implements a new semantics which ensures that strict
patterns (i.e. ones with an explicit bang, or with -XStrict)
are evaluated fully when bound.
* There are extensive notes in DsUtils:
Note [mkSelectorBinds]
* To do this I found I need one-tuples;
see Note [One-tuples] in TysWiredIn
I updated the user manual to give the new semantics
Diffstat (limited to 'libraries/ghc-prim')
-rw-r--r-- | libraries/ghc-prim/GHC/Tuple.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libraries/ghc-prim/GHC/Tuple.hs b/libraries/ghc-prim/GHC/Tuple.hs index b08d0b4fee..05d6fbfe53 100644 --- a/libraries/ghc-prim/GHC/Tuple.hs +++ b/libraries/ghc-prim/GHC/Tuple.hs @@ -26,6 +26,11 @@ default () -- Double and Integer aren't available yet -- constructor @()@. data () = () +-- The desugarer uses 1-tuples, +-- but "()" is already used up for 0-tuples +-- See Note [One-tuples] in TysWiredIn +data Unit a = Unit a + data (a,b) = (a,b) data (a,b,c) = (a,b,c) data (a,b,c,d) = (a,b,c,d) |