• cactus's avatar
    In pattern synonym matchers, support unboxed continuation results (fixes #9783). · 474e535b
    cactus authored
    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.
    474e535b
PatSyn.lhs 10.7 KB