[commit: ghc] wip/T9783: In pattern synonym matchers, support unboxed continuation results. (8fcdab8)

git at git.haskell.org git at git.haskell.org
Sat Nov 8 05:28:01 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T9783
Link       : http://ghc.haskell.org/trac/ghc/changeset/8fcdab85c60a331a4269ac3a16829a7fc762e6bc/ghc

>---------------------------------------------------------------

commit 8fcdab85c60a331a4269ac3a16829a7fc762e6bc
Author: Dr. ERDI Gergo <gergo at erdi.hu>
Date:   Sat Nov 8 12:24:55 2014 +0800

    In pattern synonym matchers, support unboxed continuation results.
    
    This requires ensuring the continuations have arguments by adding a dummy
    Void# argument when needed. This is so that matching on a pattern synonym
    is lazy even when the result is unboxed, e.g.
    
        pattern P = ()
        f P = 0#
    
    In this case, without dummy arguments, the generated matcher's type would be
    
       $mP :: forall (r :: ?). () -> r -> r -> r
    
    which is called in `f` at type `() -> Int# -> Int# -> Int#`,
    so it would be strict, in particular, in the failure continuation
    of `patError`.
    
    We work around this by making sure both continuations have arguments:
    
      $mP :: forall (r :: ?). () -> (Void# -> r) -> (Void# -> r) -> r
    
    Of course, if `P` (and thus, the success continuation) has any arguments,
    we are only adding the extra dummy argument to the failure continuation.


>---------------------------------------------------------------

8fcdab85c60a331a4269ac3a16829a7fc762e6bc
 compiler/basicTypes/PatSyn.lhs                     | 29 ++++++++++++++++------
 compiler/deSugar/DsUtils.lhs                       |  4 ++-
 compiler/typecheck/TcPatSyn.lhs                    | 28 +++++++++++----------
 testsuite/.gitignore                               |  1 +
 testsuite/tests/patsyn/should_run/T9783.hs         | 15 +++++++++++
 .../tests/patsyn/should_run/T9783.stdout           |  2 +-
 testsuite/tests/patsyn/should_run/all.T            |  1 +
 7 files changed, 57 insertions(+), 23 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 8fcdab85c60a331a4269ac3a16829a7fc762e6bc


More information about the ghc-commits mailing list