1. 23 Jan, 2017 2 commits
    • Gabor Greif's avatar
      Typos and grammar in manual/comments · 80560e69
      Gabor Greif authored
      80560e69
    • Simon Peyton Jones's avatar
      Apply the right substitution in ty-fam improvement · 2b64e926
      Simon Peyton Jones authored
      Trac #13135 showed that we were failing to apply the
      correct substitution to the un-substituted tyvars during
      type-family improvement using injectivity.  Specifically
      in TcInteractlinjImproveEqns we need to use instFlexiX.
      
      An outright bug, easy to fix.
      
      Slight refactoring along the way.  The quantified tyars of the axiom are
      readily to hand; we don't need to take the free tyvars of the LHS
      2b64e926
  2. 22 Jan, 2017 3 commits
  3. 20 Jan, 2017 2 commits
  4. 19 Jan, 2017 1 commit
    • Richard Eisenberg's avatar
      Update levity polymorphism · e7985ed2
      Richard Eisenberg authored
      This commit implements the proposal in
      https://github.com/ghc-proposals/ghc-proposals/pull/29 and
      https://github.com/ghc-proposals/ghc-proposals/pull/35.
      
      Here are some of the pieces of that proposal:
      
      * Some of RuntimeRep's constructors have been shortened.
      
      * TupleRep and SumRep are now parameterized over a list of RuntimeReps.
      * This
      means that two types with the same kind surely have the same
      representation.
      Previously, all unboxed tuples had the same kind, and thus the fact
      above was
      false.
      
      * RepType.typePrimRep and friends now return a *list* of PrimReps. These
      functions can now work successfully on unboxed tuples. This change is
      necessary because we allow abstraction over unboxed tuple types and so
      cannot
      always handle unboxed tuples specially as we did before.
      
      * We sometimes have to create an Id from a PrimRep. I thus split PtrRep
      * into
      LiftedRep and UnliftedRep, so that the created Ids have the right
      strictness.
      
      * The RepType.RepType type was removed, as it didn't seem to help with
      * much.
      
      * The RepType.repType function is also removed, in favor of typePrimRep.
      
      * I have waffled a good deal on whether or not to keep VoidRep in
      TyCon.PrimRep. In the end, I decided to keep it there. PrimRep is *not*
      represented in RuntimeRep, and typePrimRep will never return a list
      including
      VoidRep. But it's handy to have in, e.g., ByteCodeGen and friends. I can
      imagine another design choice where we have a PrimRepV type that is
      PrimRep
      with an extra constructor. That seemed to be a heavier design, though,
      and I'm
      not sure what the benefit would be.
      
      * The last, unused vestiges of # (unliftedTypeKind) have been removed.
      
      * There were several pretty-printing bugs that this change exposed;
      * these are fixed.
      
      * We previously checked for levity polymorphism in the types of binders.
      * But we
      also must exclude levity polymorphism in function arguments. This is
      hard to check
      for, requiring a good deal of care in the desugarer. See Note [Levity
      polymorphism
      checking] in DsMonad.
      
      * In order to efficiently check for levity polymorphism in functions, it
      * was necessary
      to add a new bit of IdInfo. See Note [Levity info] in IdInfo.
      
      * It is now safe for unlifted types to be unsaturated in Core. Core Lint
      * is updated
      accordingly.
      
      * We can only know strictness after zonking, so several checks around
      * strictness
      in the type-checker (checkStrictBinds, the check for unlifted variables
      under a ~
      pattern) have been moved to the desugarer.
      
      * Along the way, I improved the treatment of unlifted vs. banged
      * bindings. See
      Note [Strict binds checks] in DsBinds and #13075.
      
      * Now that we print type-checked source, we must be careful to print
      * ConLikes correctly.
      This is facilitated by a new HsConLikeOut constructor to HsExpr.
      Particularly troublesome
      are unlifted pattern synonyms that get an extra void# argument.
      
      * Includes a submodule update for haddock, getting rid of #.
      
      * New testcases:
        typecheck/should_fail/StrictBinds
        typecheck/should_fail/T12973
        typecheck/should_run/StrictPats
        typecheck/should_run/T12809
        typecheck/should_fail/T13105
        patsyn/should_fail/UnliftedPSBind
        typecheck/should_fail/LevPolyBounded
        typecheck/should_compile/T12987
        typecheck/should_compile/T11736
      
      * Fixed tickets:
        #12809
        #12973
        #11736
        #13075
        #12987
      
      * This also adds a test case for #13105. This test case is
      * "compile_fail" and
      succeeds, because I want the testsuite to monitor the error message.
      When #13105 is fixed, the test case will compile cleanly.
      e7985ed2
  5. 18 Jan, 2017 2 commits
  6. 17 Jan, 2017 1 commit
    • David Feuer's avatar
      Split mkInlineUnfolding into two functions · d360ec39
      David Feuer authored
      Previously, `mkInlineUnfolding` took a `Maybe` argument indicating
      whether the caller requested a specific arity.  This was not
      self-documenting at call sites. Now we distinguish between
      `mkInlineUnfolding` and `mkInlineUnfoldingWithArity`.
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2933
      d360ec39
  7. 13 Jan, 2017 2 commits
  8. 12 Jan, 2017 3 commits
    • Simon Peyton Jones's avatar
      Fix top-level constraint handling (Trac #12921) · f5f6d423
      Simon Peyton Jones authored
      Some out-of-scope errors were not being reported if anyone
      throws an un-caught exception in the TcM monad.  That led to
      
        ghc: panic! (the 'impossible' happened)
      	initTc: unsolved constraints
      
      I fixed this
      
      * Splitting captureConstraints to use an auxilliary
        tryCaptureConstraints (which never fails)
      
      * Define a new TcSimplify.captureTopConstraints (replacing
        the old TcRnMonad.captureTopConstraints), which reports
        any unsolved out-of-scope constraints before propagating
        the exception
      
      That in turn allowed me to do some tidying up of the static-constraint
      machinery, reducing duplication.
      
      Also solves #13106.
      f5f6d423
    • Simon Peyton Jones's avatar
      Small refactoring in TcErrors · 89ce9cd3
      Simon Peyton Jones authored
      No change in behaviour
      89ce9cd3
    • Gabor Greif's avatar
      Typos in manual, comments and tests · c6b04865
      Gabor Greif authored
      c6b04865
  9. 11 Jan, 2017 6 commits
    • Edward Z. Yang's avatar
      Fix handling of closed type families in Backpack. · f59aad68
      Edward Z. Yang authored
      Summary:
      A few related problems:
      
      - CoAxioms, like DFuns, are implicit and never exported,
        so we have to make sure we treat them the same way as
        DFuns: in RnModIface we need to rename references to
        them with rnIfaceImplicit and in mergeSignatures we need
        to NOT check them directly for compatibility (the
        test on the type family will do this check for us.)
      
      - But actually, we weren't checking if the axioms WERE
        consistent.  This is because we were forwarding all
        embedded CoAxiom references in the type family TyThing
        to the merged version, but that reference was what
        checkBootDeclM was using as a comparison point.
        This is similar to a problem we saw with DFuns.
      
        To fix this, I refactored the handling of implicit entities in TcIface
        for Backpack.  See Note [The implicit TypeEnv] for the gory details.
        Instead of passing the TypeEnv around explicitly, we stuffed it in
        IfLclEnv.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: bgamari, simonpj, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2928
      f59aad68
    • Edward Z. Yang's avatar
      Revamp Backpack/hs-boot handling of type class signatures. · 5def07fa
      Edward Z. Yang authored
      Summary:
      A basket of fixes and improvements:
      
      - The permissible things that one can write in a type
        class definition in an hsig file has been reduced
        to encompass the following things:
      
          - Methods
          - Default method signatures (but NOT implementation)
          - MINIMAL pragma
      
        It is no longer necessary nor encouraged to specify
        that a method has a default if it is mentioned in
        a MINIMAL pragma; the MINIMAL pragma is assumed to
        provide the base truth as to what methods need to
        be implemented when writing instances of a type
        class.
      
      - Handling of default method signatures in hsig was
        previously buggy, as these identifiers were not exported,
        so we now treat them similarly to DFuns.
      
      - Default methods are merged, where methods with defaults
        override those without.
      
      - MINIMAL pragmas are merged by ORing together pragmas.
      
      - Matching has been relaxed: a method with a default can
        be used to fill a signature which did not declare the
        method as having a default, and a more relaxed MINIMAL
        pragma can be used (we check if the signature pragma
        implies the final implementation pragma, on the way
        fixing a bug with BooleanFormula.implies, see #13073)
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, bgamari, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2925
      
      GHC Trac Issues: #13041
      5def07fa
    • Edward Z. Yang's avatar
      Improve Backpack support for fixities. · e41c61fa
      Edward Z. Yang authored
      Summary:
      Two major bug-fixes:
      
          - Check that fixities match between hsig and implementation
      
          - Merge and preserve fixities when merging signatures
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: bgamari, simonpj, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2919
      
      GHC Trac Issues: #13066
      e41c61fa
    • Edward Z. Yang's avatar
      Warn if you explicitly export an identifier with warning attached. · 0bbcf76a
      Edward Z. Yang authored
      Summary:
      This won't stop people from attempting to use this identifier
      (since it is still always going to be in the export list), but
      having an explicit reference to something people shouldn't
      use is a smell, so warn about it.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2907
      0bbcf76a
    • Edward Z. Yang's avatar
      Attach warnings to non-PVP compatible uses of signatures. · 9f169bcd
      Edward Z. Yang authored
      Summary:
      If you use an inherited signature from another package in your own code,
      the only valid PVP bound you can specify for this package is an *exact*
      version bound.  This is because the signature is used both covariantly
      (it provides declarations for import) and contravariantly (it specifies
      what is required).  However, this is a bit distressing if you want to
      use a PVP-style bound that allows for upgrading a package.  So there is
      a dichotomy:
      
          1. Any signatures that come from packages with exact bounds
          (this includes, in particular, signature packages, who are
          included solely to make declarations available), can be
          used without problem by modules, but
      
          2. Any signatures that come from packages that are version
          bounded (i.e., any package that also provides modules) must
          NOT be used, because if they were used, they could break
          under a PVP policy that allows relaxations in the needed
          requirements.
      
      To help users avoid situation (2), I've added a warning to all
      signature declarations that come solely from (2).  This is not
      perfect; you might still end up relying on some type identity
      specified by a signature in a version-bounded package, but it
      should help catch major errors.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2906
      9f169bcd
    • Edward Z. Yang's avatar
      Support for using only partial pieces of included signatures. · 5f9c6d2a
      Edward Z. Yang authored
      Summary:
      Generally speaking, it's not possible to "hide" a requirement from a
      package you include, because if there is some module relying on that
      requirement, well, you can't just wish it out of existence.
      
      However, some packages don't have any modules.  For these, we can
      validly thin out requirements; indeed, this is very convenient if
      someone has published a large signature package but you only want
      some of the definitions.
      
      This patchset tweaks the interpretation of export lists in
      signatures: in particular, they no longer need to refer to
      entities that are defined locally; they range over both the current
      signature as well as any signatures that were inherited from
      signature packages (defined by having zero exposed modules.)
      
      In the process of doing this, I cleaned up a number of other
      things:
      
      * rnModIface and rnModExports now report errors that occurred
        during renaming and can propagate these to the TcM monad.
        This is important because in the current semantics, you can
        thin out a type which is referenced by a value you keep;
        in this situation, we need to error (to ensure that all
        types in signatures are rooted, so that we can determine
        their identities).
      
      * I ended up introducing a new construct 'dependency signature;
        to bkp files, to make it easier to tell if we were depending
        on a signature package.  It's not difficult for Cabal to
        figure this out (I already have a patch for it.)
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2904
      
      GHC Trac Issues: #12994
      5f9c6d2a
  10. 10 Jan, 2017 1 commit
  11. 09 Jan, 2017 2 commits
  12. 06 Jan, 2017 1 commit
  13. 02 Jan, 2017 1 commit
  14. 21 Dec, 2016 2 commits
    • Simon Peyton Jones's avatar
      Fix 'SPECIALISE instance' · 1a4c04b1
      Simon Peyton Jones authored
      Trac #12944 showed that the DsBinds code that implemented a
      SPECIALISE pragma was inadequate if the constraints solving
      added let-bindings for dictionaries.  The result was that
      we ended up with an unbound dictionary in a DFunUnfolding -- and
      Lint didn't even check for that!
      
      Fixing this was not entirely straightforward
      
      * In DsBinds.dsSpec we use a new function
           TcEvidence.collectHsWrapBinders
        to pick off the lambda binders from the HsWapper
      
      * dsWrapper now returns a (CoreExpr -> CoreExpr) function
      
      * CoreUnfold.specUnfolding now takes a (CoreExpr -> CoreExpr)
        function it can use to specialise the unfolding.
      
      On the whole the code is simpler than before.
      1a4c04b1
    • Simon Peyton Jones's avatar
      Test Trac #12968, plus some comments · f97d4899
      Simon Peyton Jones authored
      f97d4899
  15. 20 Dec, 2016 1 commit
  16. 19 Dec, 2016 1 commit
  17. 18 Dec, 2016 3 commits
  18. 17 Dec, 2016 2 commits
    • eir@cis.upenn.edu's avatar
      Reshuffle levity polymorphism checks. · 8906e7b7
      eir@cis.upenn.edu authored
      Previously, GHC checked for bad levity polymorphism to the left of all
      arrows in data constructors. This was wrong, as reported in #12911
      (where an example is also shown). The solution is to check each
      individual argument for bad levity polymorphism.  Thus the check has
      been moved from TcValidity to TcTyClsDecls.
      
      A similar situation exists with pattern synonyms, also fixed here.
      
      This patch also nabs #12819 while I was in town.
      
      Test cases: typecheck/should_compile/T12911, patsyn/should_fail/T12819
      
      Test Plan: ./validate
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2783
      
      GHC Trac Issues: #12819, #12911
      8906e7b7
    • Ben Gamari's avatar
      Revert "Do not init record accessors as exported" · 0af959b1
      Ben Gamari authored
      This reverts commit 3a00ff92 due
      to #12993
      0af959b1
  19. 16 Dec, 2016 2 commits
    • Ben Gamari's avatar
      CLabel: Kill redundant UnitId argument from labelDynamic · 5bf344b7
      Ben Gamari authored
      It already has access to the current package's UnitId via the Module.
      Edward Yang pointed out that there is one wrinkle, however: the
      following invariant isn't true at all stages of compilation,
      
          if I am compiling the module (this_mod :: Module), then
          thisPackage dflags == moduleUnitId this_mod.
      
      Specifically, this is only true after desugaring; it may be broken when
      typechecking an indefinite signature.
      
      However, it's safe to assume this in the native codegen. I've updated
      Note to state this invariant more directly.
      
      Test Plan: Validate
      
      Reviewers: austin, ezyang, simonmar
      
      Reviewed By: ezyang, simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2863
      5bf344b7
    • Gabor Greif's avatar
      Typos in comments · ed4cf039
      Gabor Greif authored
      ed4cf039
  20. 15 Dec, 2016 2 commits