1. 21 Oct, 2016 2 commits
    • Simon Peyton Jones's avatar
      Refactor typechecking of pattern bindings · 45bfd1a6
      Simon Peyton Jones authored
      This patch fixes a regression introduced, post 8.0.1, by
      this major commit:
      
           commit 15b9bf4b
           Author: Simon Peyton Jones <simonpj@microsoft.com>
           Date:   Sat Jun 11 23:49:27 2016 +0100
      
               Improve typechecking of let-bindings
      
               This major commit was initially triggered by #11339, but it
               spiraled into a major review of the way in which type
               signatures for bindings are handled, especially partial type
               signatures.
      
      I didn't get the typechecking of pattern bindings right, leading
      to Trac #12427.
      
      In fixing this I found that this program doesn't work:
      
        data T where
          T :: a -> ((forall b. [b]->[b]) -> Int) -> T
      
        h1 y = case y of T _ v -> v
      
      Works in 7.10, but not in 8.0.1.
      
      There's a happy ending. I found a way to fix this, and improve
      pattern bindings too.  Not only does this fix #12427, but it also
      allows
      
      In particular,we now can accept
      
        data T where MkT :: a -> Int -> T
      
        ... let { MkT _ q = t } in ...
      
      Previously this elicited "my head exploded" but it's really
      fine since q::Int.
      
      The approach is described in detail in TcBinds
         Note [Typechecking pattern bindings]
      Super cool.  And not even a big patch!
      45bfd1a6
    • Gabor Greif's avatar
      Typos in comments · ff225b49
      Gabor Greif authored
      ff225b49
  2. 20 Oct, 2016 6 commits
    • Ben Gamari's avatar
      check-cpp: Make it more robust · c23dc616
      Ben Gamari authored
      Catch more than one space
      c23dc616
    • Edward Z. Yang's avatar
    • Edward Z. Yang's avatar
    • Edward Z. Yang's avatar
      Only delete instances when merging when there is an exact match. · 9df4ce4f
      Edward Z. Yang authored
      Summary:
      Previously, we deleted if the heads matched, which meant that
      we effectively were picking an arbitrary instance if there
      were incompatible instances.  The new behavior makes more sense,
      although without incoherent instances you are unlikely to
      be able to do anything useful with the instances.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2596
      9df4ce4f
    • Edward Z. Yang's avatar
      Support constraint synonym implementations of abstract classes. · 7e77c4b2
      Edward Z. Yang authored
      Summary:
      
      Test Plan: validate
      
      Reviewers: goldfire, simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2595
      
      GHC Trac Issues: #12679
      7e77c4b2
    • Edward Z. Yang's avatar
      New story for abstract data types in hsig files. · 518f2895
      Edward Z. Yang authored
      Summary:
      In the old implementation of hsig files, we directly
      reused the implementation of abstract data types from
      hs-boot files.  However, this was WRONG.  Consider the
      following program (an abridged version of bkpfail24):
      
          {-# LANGUAGE GADTs #-}
          unit p where
              signature H1 where
                  data T
              signature H2 where
                  data T
              module M where
                  import qualified H1
                  import qualified H2
      
                  f :: H1.T ~ H2.T => a -> b
                  f x = x
      
      Prior to this patch, M was accepted, because the type
      inference engine concluded that H1.T ~ H2.T does not
      hold (indeed, *presently*, it does not).  However, if
      we subsequently instantiate p with the same module for
      H1 and H2, H1.T ~ H2.T does hold!  Unsound.
      
      The key is that abstract types from signatures need to
      be treated like *skolem variables*, since you can interpret
      a Backpack unit as a record which is universally quantified
      over all of its abstract types, as such (with some fake
      syntax for structural records):
      
          p :: forall t1 t2. { f :: t1 ~ t2 => a -> b }
          p = { f = \x -> x } -- ill-typed
      
      Clearly t1 ~ t2 is not solvable inside p, and also clearly
      it could be true at some point in the future, so we better
      not treat the lambda expression after f as inaccessible.
      
      The fix seems to be simple: do NOT eagerly fail when trying
      to simplify the given constraints.  Instead, treat H1.T ~ H2.T
      as an irreducible constraint (rather than an insoluble
      one); this causes GHC to treat f as accessible--now we will
      typecheck the rest of the function (and correctly fail).
      Per the OutsideIn(X) paper, it's always sound to fail less
      when simplifying givens.
      
      We do NOT apply this fix to hs-boot files, where abstract
      data is also guaranteed to be nominally distinct (since
      it can't be implemented via a reexport or a type synonym.)
      This is a somewhat unnatural state of affairs (there's
      no way to really interpret this in Haskell land) but
      no reason to change behavior.
      
      I deleted "representationally distinct abstract data",
      which is never used anywhere in GHC.
      
      In the process of constructing this fix, I also realized
      our implementation of type synonym matching against abstract
      data was not sufficiently restrictive.  In order for
      a type synonym T to be well-formed type, it must be a
      nullary synonym (i.e., type T :: * -> *, not type T a = ...).
      Furthermore, since we use abstract data when defining
      instances, they must not have any type family applications.
      
      More details in #12680.  This probably deserves some sort
      of short paper report.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: goldfire, simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2594
      518f2895
  3. 19 Oct, 2016 6 commits
  4. 18 Oct, 2016 7 commits
  5. 17 Oct, 2016 19 commits