1. 02 Sep, 2017 4 commits
    • Ryan Scott's avatar
      Fix #14167 by using isGadtSyntaxTyCon in more places · 8e4229ab
      Ryan Scott authored
      Two places in GHC effectively attempt to //guess// whether a data type
      was declared using GADT syntax:
      1. When reifying a data type in Template Haskell
      2. When pretty-printing a data type (e.g., via `:info` in GHCi)
      But there's no need for heuristics here, since we have a 100% accurate way to
      determine whether a data type was declared using GADT syntax: the
      `isGadtSyntaxTyCon` function! By simply using that as the metric, we obtain
      far more accurate TH reification and pretty-printing results.
      This is technically a breaking change, since Template Haskell reification will
      now reify some data type constructors as `(Rec)GadtC` that it didn't before,
      and some data type constructors that were previously reified as `(Rec)GadtC`
      will no longer be reified as such. But it's a very understandable breaking
      change, since the previous behavior was simply incorrect.
      Test Plan: ./validate
      Reviewers: simonpj, goldfire, austin, bgamari
      Reviewed By: simonpj
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #14167
      Differential Revision: https://phabricator.haskell.org/D3901
    • Ryan Scott's avatar
      Disallow bang/lazy patterns in the RHSes of implicitly bidirectional patsyns · 5dd6b13c
      Ryan Scott authored
      GHC was allowing implicitly bidirectional pattern synonyms with bang
      patterns and irrefutable patterns in the RHS, like so:
      pattern StrictJust a = Just !a
      This has multiple problems:
      1. `Just !a` isn't a valid expression, so it feels strange to allow it in an
         implicitly bidirectional pattern synonym.
      2. `StrictJust` doesn't provide the strictness properties one would expect
         from a strict constructor. (One could imagine a design where the
         `StrictJust` builder infers a bang pattern for its pattern variable, but
         accomplishing this inference in a way that accounts for all possible
         patterns on the RHS, including other pattern synonyms, is somewhat
         awkward, so we do not pursue this design.)
      We nip these issues in the bud by simply disallowing bang/irrefutable patterns
      on the RHS.
      Test Plan: make test TEST="T14112 unidir"
      Reviewers: simonpj, austin, bgamari
      Reviewed By: simonpj
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #14112
      Differential Revision: https://phabricator.haskell.org/D3896
    • Ryan Scott's avatar
      Document the intricacies of ForallC variable quantification better · 6330b0b0
      Ryan Scott authored
      I recently (re-)discovered that `ForallC` quantifies different type variables
      depending on whether `GadtC` is present or not. This is an important
      enough gotcha where I feel like this fact should also be advertised in the
      `template-haskell` documentation itself, so this patch does just that.
      Test Plan: Read it
      Reviewers: goldfire, austin, bgamari
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #13885
      Differential Revision: https://phabricator.haskell.org/D3880
    • Herbert Valerio Riedel's avatar
      Update transformers submodule · 590e7376
      Herbert Valerio Riedel authored
      This updates `transformers` from the v0.5.2 release to the
      v0.5.4 release + unreleased changes
      This is a pre-requisite for the Semigroup=>Monoid implementation
  2. 01 Sep, 2017 4 commits
  3. 31 Aug, 2017 5 commits
    • Herbert Valerio Riedel's avatar
      Add missing Semigroup instances in utils/{hpc,runghc} · b2c2e3e8
      Herbert Valerio Riedel authored
      This is a follow-up to c0feee90
    • Herbert Valerio Riedel's avatar
      Add missing Semigroup instances to compiler · c0feee90
      Herbert Valerio Riedel authored
      This is a pre-requisite for implementing the Semigroup/Monoid proposal.
      The instances have been introduced in a way to minimise warnings.
    • Simon Peyton Jones's avatar
      Really fix Trac #14158 · 2c133b67
      Simon Peyton Jones authored
      I dug more into how #14158 started working. I temporarily reverted the
      patch that "fixed" it, namely
          commit a6c448b4
          Author: Simon Peyton Jones <simonpj@microsoft.com>
          Date:   Mon Aug 28 17:33:59 2017 +0100
          Small refactor of getRuntimeRep
      Sure enough, there was a real bug, described in the new
      TcExpr Note [Visible type application zonk]
      In general, syntactic substituion should be kind-preserving!
      Maybe we should check that invariant...
    • Simon Peyton Jones's avatar
      Small changes to ddump-tc tracing · 3790ea90
      Simon Peyton Jones authored
    • Simon Peyton Jones's avatar
      Add debugPprType · 805b29bb
      Simon Peyton Jones authored
      We pretty-print a type by converting it to an IfaceType and
      pretty-printing that.  But
       (a) that's a bit indirect, and
       (b) delibrately loses information about (e.g.) the kind
            on the /occurrences/ of a type variable
      So this patch implements debugPprType, which pretty prints
      the type directly, with no fancy formatting.  It's just used
      for debugging.
      I took the opportunity to refactor the debug-pretty-printing
      machinery a little.  In particular, define these functions
      and use them:
        ifPprDeubug :: SDoc -> SDOc -> SDoc
          -- Says what to do with and without -dppr-debug
        whenPprDebug :: SDoc -> SDoc
          -- Says what to do with  -dppr-debug; without is empty
        getPprDebug :: (Bool -> SDoc) -> SDoc
      getPprDebug used to be called sdocPprDebugWith
      whenPprDebug used to be called ifPprDebug
      So a lot of files get touched in a very mechanical way
  4. 30 Aug, 2017 3 commits
    • Simon Peyton Jones's avatar
      Define and use HsArg · fca19628
      Simon Peyton Jones authored
      All this Left/Right business was making my head spin, so I defined
      data HsArg tm ty
        = HsValArg tm   -- Argument is an ordinary expression     (f arg)
        | HsTypeArg  ty -- Argument is a visible type application (f @ty)
      and used it.  This is just simple refactor; no change in behaviour.
    • Simon Peyton Jones's avatar
      Add comments to RnTypes · 628b6669
      Simon Peyton Jones authored
      These comments clarify the details of:
        commit 0257dacf
        Author: Simon Peyton Jones <simonpj@microsoft.com>
        Date:   Mon Aug 28 14:20:02 2017 +0100
            Refactor bindHsQTyVars and friends
    • Simon Peyton Jones's avatar
      Add some traceRn and (Outputable StmtTree) · 567dca6e
      Simon Peyton Jones authored
      I added these when investigating Trac #14163, but they'll be
      useful anyway.
  5. 29 Aug, 2017 24 commits
    • Ben Gamari's avatar
      Add a Note describing #14128 · 6f1ccaa5
      Ben Gamari authored
      I prematurely committed the D3892 before adding a Note. Fix this.
    • James Michael DuPont's avatar
      HsExpr: Fix typo · 15615254
      James Michael DuPont authored
    • Ben Gamari's avatar
      StgLint: Give up on trying to compare types · f17f1063
      Ben Gamari authored
      We used to try a crude comparison of the type themselves, but this is
      essentially impossible in STG as we have discarded. both casts and type
      applications, so types might look different but be the same.  Now we
      simply compare their runtime representations.
      See #14120.
      Reviewers: austin
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #14120
      Differential Revision: https://phabricator.haskell.org/D3879
    • Ben Gamari's avatar
      StgLint: Enforce MultiValAlt liveness invariant only after unariser · a36b34c4
      Ben Gamari authored
      The unariser ensures that we never use case binders that are void,
      unboxed sums, or unboxed tuples. However, previously StgLint was
      enforcing this invariant even before the unariser was running, giving
      rise to spurious lint failures.  Fix this. Following CoreLint, we
      introduce a LintFlags environment to the linter monad, allowing for
      additional flags to be easily accomodated in the future.
      See #14118.
      Test Plan: Build GHC with -dstg-lint
      Reviewers: simonpj, austin
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #14118
      Differential Revision: https://phabricator.haskell.org/D3889
    • Ben Gamari's avatar
      StgLint: Show type of out-of-scope binders · 651b4dc7
      Ben Gamari authored
      Reviewers: austin
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3887
    • Ben Gamari's avatar
      nativeGen: Don't index into linked lists · 9d57d8c1
      Ben Gamari authored
      There were a couple places where we indexed into linked lists of
      register names.  Replace these with arrays.
      Reviewers: austin
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3893
    • Ben Gamari's avatar
      PackageDb: Explicitly unlock package database before closing · 779b9e69
      Ben Gamari authored
      Reviewers: austin
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #13945
      Differential Revision: https://phabricator.haskell.org/D3874
    • Ben Gamari's avatar
      base: Add support for file unlocking · a27bb1bd
      Ben Gamari authored
      Reviewers: austin, hvr
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3875
    • Ben Gamari's avatar
      ghc-pkg: Try opening lockfiles in read-write mode first · f86de44d
      Ben Gamari authored
      As pointed out in #13945, some filesystems only allow allow exclusive
      locks if the fd being locked was opened for write access. This causes
      ghc-pkg to fail as it first attempts to open and exclusively lock its
      lockfile in read-only mode to accomodate package databases for which we
      lack write permissions (e.g.  global package databases).
      Instead, we now try read-write mode first, falling back to read-only
      mode if this fails.
      Reviewers: austin
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #13945
      Differential Revision: https://phabricator.haskell.org/D3897
    • Tamar Christina's avatar
      Add gen-dll as replacement for dll-split · 5f6a8204
      Tamar Christina authored
      This tool can be used to generate dll's for any list of object files
      given to it. It will then repartition them automatically to fit within
      a dll and generates as many dll's as needed to do this. Cyclic dependencies
      between these generated dlls are handle automatically so there is no need
      to tell it how to partition.
      It is also a lot more general than `dll-split` as it is able to split any
      package not just `libGHC`. It also uses a trick using GNU style import libraries
      to hide the splitting from the rest of the pipeline. Which means come linking time
      you don't need to know which dll contains what symbol or how many split dlls were
      The import libraries are by default created with libtool. However since libtool is BFD
      based it is very slow. So if present and detected by configure the `genlib` tool
      from the msys2 project is used. This makes a difference of about ~45 minutes when compiling.
      To install `genlib` run `pacman -Sy mingw-w64-$(uname -m)-tools-git`.
      More detailed explaination of the process can be found here
      Test Plan: ./validate
      Reviewers: austin, hvr, bgamari, erikd, simonmar
      Reviewed By: bgamari
      Subscribers: snowleopard, rwbarton, thomie, erikd, #ghc_windows_task_force
      GHC Trac Issues: #5987
      Differential Revision: https://phabricator.haskell.org/D3883
    • Tamar Christina's avatar
      Fix decomposition error on Windows · 3c6b2fc3
      Tamar Christina authored
      Fix the path decomposition error that occurs when the Symlink resolver
      fails. `Win32.try` throws an exception, so catch it and assume the path
      isn't a symlink to use the old behavior.
      Test Plan: ./validate
      Reviewers: austin, bgamari
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #14159
      Differential Revision: https://phabricator.haskell.org/D3891
    • Ryan Scott's avatar
      Refactor type family instance abstract syntax declarations · 895a7650
      Ryan Scott authored
      This implements @simonpj's suggested refactoring of the abstract syntax
      for type/data family instances (from
      https://ghc.haskell.org/trac/ghc/ticket/14131#comment:9). This combines
      the previously separate `TyFamEqn` and `DataFamInstDecl` types into a
      single `FamEqn` datatype. This also factors the `HsImplicitBndrs` out of
      `HsTyPats` in favor of putting them just outside of `FamEqn` (as opposed
      to before, where all of the implicit binders were embedded inside of
      `TyFamEqn`/`DataFamInstDecl`). Finally, along the way I noticed that
      `dfid_fvs` and `tfid_fvs` were completely unused, so I removed them.
      Aside from some changes in parser test output, there is no change in
      Requires a Haddock submodule commit from my fork (at
      Test Plan: ./validate
      Reviewers: simonpj, austin, goldfire, bgamari, alanz
      Reviewed By: bgamari
      Subscribers: mpickering, goldfire, rwbarton, thomie, simonpj
      GHC Trac Issues: #14131
      Differential Revision: https://phabricator.haskell.org/D3881
    • Tamar Christina's avatar
      Remove dll-split. · 5266ab90
      Tamar Christina authored
      This patch removes dll-split from the code base, the reason is dll-split
      no longer makes any sense. It was designed to split a dll in two, but we
      now already have many more symbols than would fit inside two dlls. So we
      need a third one. This means there's no point in having to maintain this
      list as it'll never work anyway and the solution isn't scalable.
      Test Plan: ./validate
      Reviewers: austin, bgamari
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie, #ghc_windows_task_force
      GHC Trac Issues: #5987
      Differential Revision: https://phabricator.haskell.org/D3882
    • Ben Gamari's avatar
      desugar: Ensure that a module's dep_orphs doesn't contain itself · db3a8e16
      Ben Gamari authored
      Consider that we have two modules, A and B, both with hs-boot files,
        * A.hs contains a SOURCE import of B
        * B.hs-boot contains a SOURCE import of A
        * A.hs-boot declares an orphan instance
        * A.hs defines the orphan instance
      In this case, B's dep_orphs will contain A due to its SOURCE import of
      A.  Consequently, A will contain itself in its imp_orphs due to its
      import of B.  This fact would end up being recorded in A's interface
      file. This would then break the invariant asserted by calculateAvails
      that a module does not itself in its dep_orphs. This was the cause
      of #14128.
      The solution is to remove self-references from imp_orphs when
      constructing dep_orphs; we already did a similar thing for dep_mods. I
      believe we should do the same for dep_finsts, although I'm treating this
      as a separate bug.
      Reviewers: austin
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3892
    • Ben Gamari's avatar
      testsuite: Add test for #14128 · 248ad303
      Ben Gamari authored
      Reviewers: austin, goldfire
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #14128
      Differential Revision: https://phabricator.haskell.org/D3890
    • Simon Peyton Jones's avatar
      Add HasDebugStack for typeKind · aed7d431
      Simon Peyton Jones authored
      typeKind can fail, and it's called all over the place, so
      it's helpful to know where
    • Simon Peyton Jones's avatar
      Small refactor of getRuntimeRep · a6c448b4
      Simon Peyton Jones authored
      Instead of using a string argument, use HasDebugCallStack.
      (Oddly, some functions were using both!)
      Plus, use getRuntimeRep rather than getRuntimeRep_maybe when
      if the caller panics on Nothing. Less code, and a better debug
    • Simon Peyton Jones's avatar
    • Simon Peyton Jones's avatar
      Use a well-kinded substitution to instantiate · 4455c86d
      Simon Peyton Jones authored
      In tcDataConPat we were creating an ill-kinded substitution
      -- or at least one that is well kinded only after you have solved
      other equalities.  THat led to a crash, because the instantiated
      data con type was ill-kinded.
      This patch guarantees that the instantiating substitution is
      Fixed Trac #14154
    • Simon Peyton Jones's avatar
      Small refactoring of meta-tyvar cloning · 86e6a5f2
      Simon Peyton Jones authored
      No change in behaviour.
    • Simon Peyton Jones's avatar
      Refactor bindHsQTyVars and friends · 0257dacf
      Simon Peyton Jones authored
      This work was triggered by Trac #13738, which revealed to me that
      the code RnTypes.bindHsQTyVars and bindLHsTyVarBndrs was a huge
      tangled mess -- and outright wrong on occasion as the ticket showed.
      The big problem was that bindLHsTyVarBndrs (which is invoked at every
      HsForAll, including nested higher rank ones) was attempting to bind
      implicit kind variables, which it has absolutely no busineess doing.
      Imlicit kind quantification is done at the outside only, in fact
      precisely where we have HsImplicitBndrs or LHsQTyVars (which also
      has implicit binders).
      Achieving this move was surprisingly hard, because more and more
      barnacles had accreted aroud the original mistake.  It's much
      much better now.
      Summary of changes.  Almost all the action is in RnTypes.
      * Implicit kind variables are bound only by
        - By bindHsQTyVars, which deals with LHsQTyVars
        - By rnImplicitBndrs, which deals with HsImplicitBndrs
      * bindLHsTyVarBndrs, and bindLHsTyVarBndr are radically simplified.
        They simply does far less, and have lots their forest of
        incomprehensible accumulating parameters.  (To be fair, some of
        the code in bindLHsTyVarBndrs just moved to bindHsQTyVars, but
        in much more perspicuous form.)
      * The code that checks if a variable appears in both a kind and
        a type (triggering RnTypes.mixedVarsErr) was bizarre.  E.g.
        we had this in RnTypes.extract_hs_tv_bndrs
             ; check_for_mixed_vars bndr_kvs acc_tvs
             ; check_for_mixed_vars bndr_kvs body_tvs
             ; check_for_mixed_vars body_tvs acc_kvs
             ; check_for_mixed_vars body_kvs acc_tvs
             ; check_for_mixed_vars locals body_kvs
        I cleaned all this up; now we check for mixed use at binding
        sites only.
      * Checks for "Variable used as a kind before being bound", like
           data T (a :: k) k = rhs
        now just show up straightforwardly as "k is not in scope".
        See Note [Kind variable ordering]
      * There are some knock-on simplifications in RnSource.
    • Simon Peyton Jones's avatar
      Add TcRnMonad.unlessXOptM · 6f050d9c
      Simon Peyton Jones authored
      This usefully joins whenXOptM; there are probably lots of places
      we should use it!
      This patch does not use new new function at all; but it's preparing
      for an upcoming patch when I do use it.
    • Simon Peyton Jones's avatar
      A bit more -ddump-tc tracing · 547e4c03
      Simon Peyton Jones authored
    • Simon Peyton Jones's avatar
      Better debug-printing for Outputable TyConBinder · 8834d482
      Simon Peyton Jones authored
      Anon and Required were printed the same :-(.  This is only for
      debug printing, so I switched to a slightly more verbose and
      explicit format