1. 25 Jan, 2020 4 commits
    • Sylvain Henry's avatar
      Module hierarchy: Cmm (cf #13009) · 6e2d9ee2
      Sylvain Henry authored
      6e2d9ee2
    • Ryan Scott's avatar
      Handle local fixity declarations in DsMeta properly · c3fde723
      Ryan Scott authored
      `DsMeta.rep_sig` used to skip over `FixSig` entirely, which had the
      effect of causing local fixity declarations to be dropped when quoted
      in Template Haskell. But there is no good reason for this state of
      affairs, as the code in `DsMeta.repFixD` (which handles top-level
      fixity declarations) handles local fixity declarations just fine.
      This patch factors out the necessary parts of `repFixD` so that they
      can be used in `rep_sig` as well.
      
      There was one minor complication: the fixity signatures for class
      methods in each `HsGroup` were stored both in `FixSig`s _and_ the
      list of `LFixitySig`s for top-level fixity signatures, so I needed
      to take action to prevent fixity signatures for class methods being
      converted to `Dec`s twice. I tweaked `RnSource.add` to avoid putting
      these fixity signatures in two places and added
      `Note [Top-level fixity signatures in an HsGroup]` in `GHC.Hs.Decls`
      to explain the new design.
      
      Fixes #17608. Bumps the Haddock submodule.
      c3fde723
    • Sebastian Graf's avatar
      PmCheck: Properly handle constructor-bound type variables · 86966d48
      Sebastian Graf authored
      In ghc/ghc!2192 (comment 246551)
      Simon convinced me that ignoring type variables existentially bound by
      data constructors have to be the same way as value binders.
      
      Sadly I couldn't think of a regression test, but I'm confident that this
      change strictly improves on the status quo.
      86966d48
    • Sebastian Graf's avatar
      PmCheck: Formulate as translation between Clause Trees · 8038cbd9
      Sebastian Graf authored
      We used to check `GrdVec`s arising from multiple clauses and guards in
      isolation. That resulted in a split between `pmCheck` and
      `pmCheckGuards`, the implementations of which were similar, but subtly
      different in detail. Also the throttling mechanism described in
      `Note [Countering exponential blowup]` ultimately got quite complicated
      because it had to cater for both checking functions.
      
      This patch realises that pattern match checking doesn't just consider
      single guarded RHSs, but that it's always a whole set of clauses, each
      of which can have multiple guarded RHSs in turn. We do so by
      translating a list of `Match`es to a `GrdTree`:
      
      ```haskell
      data GrdTree
        = Rhs !RhsInfo
        | Guard !PmGrd !GrdTree      -- captures lef-to-right  match semantics
        | Sequence !GrdTree !GrdTree -- captures top-to-bottom match semantics
        | Empty                      -- For -XEmptyCase, neutral element of Sequence
      ```
      
      Then we have a function `checkGrdTree` that matches a given `GrdTree`
      against an incoming set of values, represented by `Deltas`:
      
      ```haskell
      checkGrdTree :: GrdTree -> Deltas -> CheckResult
      ...
      ```
      
      Throttling is isolated to the `Sequence` case and becomes as easy as one
      would expect: When the union of uncovered values becomes too big, just
      return the original incoming `Deltas` instead (which is always a
      superset of the union, thus a sound approximation).
      
      The returned `CheckResult` contains two things:
      
      1. The set of values that were not covered by any of the clauses, for
         exhaustivity warnings.
      2. The `AnnotatedTree` that enriches the syntactic structure of the
         input program with divergence and inaccessibility information.
      
      This is `AnnotatedTree`:
      
      ```haskell
      data AnnotatedTree
        = AccessibleRhs !RhsInfo
        | InaccessibleRhs !RhsInfo
        | MayDiverge !AnnotatedTree
        | SequenceAnn !AnnotatedTree !AnnotatedTree
        | EmptyAnn
      ```
      
      Crucially, `MayDiverge` asserts that the tree may force diverging
      values, so not all of its wrapped clauses can be redundant.
      
      While the set of uncovered values can be used to generate the missing
      equations for warning messages, redundant and proper inaccessible
      equations can be extracted from `AnnotatedTree` by
      `redundantAndInaccessibleRhss`.
      
      For this to work properly, the interface to the Oracle had to change.
      There's only `addPmCts` now, which takes a bag of `PmCt`s. There's a
      whole bunch of `PmCt` variants to replace the different oracle functions
      from before.
      
      The new `AnnotatedTree` structure allows for more accurate warning
      reporting (as evidenced by a number of changes spread throughout GHC's
      code base), thus we fix #17465.
      
      Fixes #17646 on the go.
      
      Metric Decrease:
          T11822
          T9233
          PmSeriesS
          haddock.compiler
      8038cbd9
  2. 20 Jan, 2020 1 commit
  3. 16 Jan, 2020 4 commits
    • Adam Wespiser's avatar
      replace dead html link (fixes #17661) · f416fe64
      Adam Wespiser authored
      f416fe64
    • John Ericson's avatar
      Remove special case case of bool during STG -> C-- · 1ff55226
      John Ericson authored
      Allow removing the no longer needed cgPrimOp, getting rid of a small a
      small layer violation too.
      
      Change which made the special case no longer needed was #6135 /
      6579a6c7, which dates back to 2013,
      making me feel better.
      1ff55226
    • John Ericson's avatar
      Get rid of OpDest · ee5d63f4
      John Ericson authored
      `OpDest` was basically a defunctionalization. Just turn the code that
      cased on it into those functions, and call them directly.
      ee5d63f4
    • John Ericson's avatar
      Handle TagToEnum in the same big case as the other primops · 22c0bdc3
      John Ericson authored
      Before, it was a panic because it was handled above. But there must have
      been an error in my reasoning (another caller?) because #17442 reported
      the panic was hit.
      
      But, rather than figuring out what happened, I can just make it
      impossible by construction. By adding just a bit more bureaucracy in the
      return types, I can handle TagToEnum in the same case as all the others,
      so the big case is is now total, and the panic is removed.
      
      Fixes #17442
      22c0bdc3
  4. 13 Jan, 2020 2 commits
  5. 08 Jan, 2020 2 commits
  6. 07 Jan, 2020 1 commit
    • Ryan Scott's avatar
      Monomorphize HsModule to GhcPs (#17642) · b69a3460
      Ryan Scott authored
      Analyzing the call sites for `HsModule` reveals that it is only ever
      used with parsed code (i.e., `GhcPs`). This simplifies `HsModule` by
      concretizing its `pass` parameter to always be `GhcPs`.
      
      Fixes #17642.
      b69a3460
  7. 06 Jan, 2020 1 commit
  8. 04 Jan, 2020 1 commit
  9. 31 Dec, 2019 1 commit
  10. 18 Dec, 2019 1 commit
    • Sylvain Henry's avatar
      Add GHC-API logging hooks · 58655b9d
      Sylvain Henry authored
      * Add 'dumpAction' hook to DynFlags.
      
      It allows GHC API users to catch dumped intermediate codes and
      information. The format of the dump (Core, Stg, raw text, etc.) is now
      reported allowing easier automatic handling.
      
      * Add 'traceAction' hook to DynFlags.
      
      Some dumps go through the trace mechanism (for instance unfoldings that
      have been considered for inlining). This is problematic because:
      1) dumps aren't written into files even with -ddump-to-file on
      2) dumps are written on stdout even with GHC API
      3) in this specific case, dumping depends on unsafe globally stored
      DynFlags which is bad for GHC API users
      
      We introduce 'traceAction' hook which allows GHC API to catch those
      traces and to avoid using globally stored DynFlags.
      
      * Avoid dumping empty logs via dumpAction/traceAction (but still write
      empty files to keep the existing behavior)
      58655b9d
  11. 17 Dec, 2019 1 commit
    • Krzysztof Gogolewski's avatar
      Use "OrCoVar" functions less · 75355fde
      Krzysztof Gogolewski authored
      As described in #17291, we'd like to separate coercions and expressions
      in a more robust fashion.
      This is a small step in this direction.
      
      - `mkLocalId` now panicks on a covar.
        Calls where this was not the case were changed to `mkLocalIdOrCoVar`.
      - Don't use "OrCoVar" functions in places where we know the type is
        not a coercion.
      75355fde
  12. 09 Dec, 2019 1 commit
    • Gabor Greif's avatar
      Fix comment typos · d46a72e1
      Gabor Greif authored
      The below is only necessary to fix the CI perf fluke that
      happened in 9897e8c8:
      -------------------------
      Metric Decrease:
          T5837
          T6048
          T9020
          T12425
          T12234
          T13035
          T12150
          Naperian
      -------------------------
      d46a72e1
  13. 07 Dec, 2019 1 commit
    • Gabor Greif's avatar
      Implement pointer tagging for big families (#14373) · 9897e8c8
      Gabor Greif authored
      Formerly we punted on these and evaluated constructors always got a tag
      of 1.
      
      We now cascade switches because we have to check the tag first and when
      it is MAX_PTR_TAG then get the precise tag from the info table and
      switch on that. The only technically tricky part is that the default
      case needs (logical) duplication. To do this we emit an extra label for
      it and branch to that from the second switch. This avoids duplicated
      codegen.
      
      Here's a simple example of the new code gen:
      
          data D = D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8
      
      On a 64-bit system previously all constructors would be tagged 1. With
      the new code gen D7 and D8 are tagged 7:
      
          [Lib.D7_con_entry() {
               ...
               {offset
                 c1eu: // global
                     R1 = R1 + 7;
                     call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
               }
           }]
      
          [Lib.D8_con_entry() {
               ...
               {offset
                 c1ez: // global
                     R1 = R1 + 7;
                     call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
               }
           }]
      
      When switching we now look at the info table only when the tag is 7. For
      example, if we derive Enum for the type above, the Cmm looks like this:
      
          c2Le:
              _s2Js::P64 = R1;
              _c2Lq::P64 = _s2Js::P64 & 7;
              switch [1 .. 7] _c2Lq::P64 {
                  case 1 : goto c2Lk;
                  case 2 : goto c2Ll;
                  case 3 : goto c2Lm;
                  case 4 : goto c2Ln;
                  case 5 : goto c2Lo;
                  case 6 : goto c2Lp;
                  case 7 : goto c2Lj;
              }
      
          // Read info table for tag
          c2Lj:
              _c2Lv::I64 = %MO_UU_Conv_W32_W64(I32[I64[_s2Js::P64 & (-8)] - 4]);
              if (_c2Lv::I64 != 6) goto c2Lu; else goto c2Lt;
      
      Generated Cmm sizes do not change too much, but binaries are very
      slightly larger, due to the fact that the new instructions are longer in
      encoded form. E.g. previously entry code for D8 above would be
      
          00000000000001c0 <Lib_D8_con_info>:
           1c0:	48 ff c3             	inc    %rbx
           1c3:	ff 65 00             	jmpq   *0x0(%rbp)
      
      With this patch
      
          00000000000001d0 <Lib_D8_con_info>:
           1d0:	48 83 c3 07          	add    $0x7,%rbx
           1d4:	ff 65 00             	jmpq   *0x0(%rbp)
      
      This is one byte longer.
      
      Secondly, reading info table directly and then switching is shorter
      
          _c1co:
                  movq -1(%rbx),%rax
                  movl -4(%rax),%eax
                  // Switch on info table tag
                  jmp *_n1d5(,%rax,8)
      
      than doing the same switch, and then for the tag 7 doing another switch:
      
          // When tag is 7
          _c1ct:
                  andq $-8,%rbx
                  movq (%rbx),%rax
                  movl -4(%rax),%eax
                  // Switch on info table tag
                  ...
      
      Some changes of binary sizes in actual programs:
      
      - In NoFib the worst case is 0.1% increase in benchmark "parser" (see
        NoFib results below). All programs get slightly larger.
      
      - Stage 2 compiler size does not change.
      
      - In "containers" (the library) size of all object files increases
        0.0005%. Size of the test program "bitqueue-properties" increases
        0.03%.
      
      nofib benchmarks kindly provided by Ömer (@osa1):
      
      NoFib Results
      =============
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs    Instrs     Reads    Writes
      --------------------------------------------------------------------------------
                   CS          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  CSD          +0.0%      0.0%      0.0%     +0.0%     +0.0%
                   FS          +0.0%      0.0%      0.0%     +0.0%      0.0%
                    S          +0.0%      0.0%     -0.0%      0.0%      0.0%
                   VS          +0.0%      0.0%     -0.0%     +0.0%     +0.0%
                  VSD          +0.0%      0.0%     -0.0%     +0.0%     -0.0%
                  VSM          +0.0%      0.0%      0.0%      0.0%      0.0%
                 anna          +0.0%      0.0%     +0.1%     -0.9%     -0.0%
                 ansi          +0.0%      0.0%     -0.0%     +0.0%     +0.0%
                 atom          +0.0%      0.0%      0.0%      0.0%      0.0%
               awards          +0.0%      0.0%     -0.0%     +0.0%      0.0%
               banner          +0.0%      0.0%     -0.0%     +0.0%      0.0%
           bernouilli          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
         binary-trees          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
                boyer          +0.0%      0.0%     +0.0%      0.0%     -0.0%
               boyer2          +0.0%      0.0%     +0.0%      0.0%     -0.0%
                 bspt          +0.0%      0.0%     +0.0%     +0.0%      0.0%
            cacheprof          +0.0%      0.0%     +0.1%     -0.8%      0.0%
             calendar          +0.0%      0.0%     -0.0%     +0.0%     -0.0%
             cichelli          +0.0%      0.0%     +0.0%      0.0%      0.0%
              circsim          +0.0%      0.0%     -0.0%     -0.1%     -0.0%
             clausify          +0.0%      0.0%     +0.0%     +0.0%      0.0%
        comp_lab_zift          +0.0%      0.0%     +0.0%      0.0%     -0.0%
             compress          +0.0%      0.0%     +0.0%     +0.0%      0.0%
            compress2          +0.0%      0.0%      0.0%      0.0%      0.0%
          constraints          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
         cryptarithm1          +0.0%      0.0%     +0.0%      0.0%      0.0%
         cryptarithm2          +0.0%      0.0%     +0.0%     -0.0%      0.0%
                  cse          +0.0%      0.0%     +0.0%     +0.0%      0.0%
         digits-of-e1          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
         digits-of-e2          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
               dom-lt          +0.0%      0.0%     +0.0%     +0.0%      0.0%
                eliza          +0.0%      0.0%     -0.0%     +0.0%      0.0%
                event          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
          exact-reals          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
               exp3_8          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
               expert          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
       fannkuch-redux          +0.0%      0.0%     +0.0%      0.0%      0.0%
                fasta          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  fem          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
                  fft          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
                 fft2          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
             fibheaps          +0.0%      0.0%     +0.0%     +0.0%      0.0%
                 fish          +0.0%      0.0%     +0.0%     +0.0%      0.0%
                fluid          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
               fulsom          +0.0%      0.0%     +0.0%     -0.0%     +0.0%
               gamteb          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
                  gcd          +0.0%      0.0%     +0.0%     +0.0%      0.0%
          gen_regexps          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
               genfft          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
                   gg          +0.0%      0.0%      0.0%     -0.0%      0.0%
                 grep          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
               hidden          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
                  hpg          +0.0%      0.0%     +0.0%     -0.1%     -0.0%
                  ida          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
                infer          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
              integer          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
            integrate          +0.0%      0.0%      0.0%     +0.0%      0.0%
         k-nucleotide          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
                kahan          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
              knights          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
               lambda          +0.0%      0.0%     +1.2%     -6.1%     -0.0%
           last-piece          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
                 lcss          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
                 life          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
                 lift          +0.0%      0.0%     +0.0%     +0.0%      0.0%
               linear          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
            listcompr          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
             listcopy          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
             maillist          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
               mandel          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
              mandel2          +0.0%      0.0%     +0.0%     +0.0%     -0.0%
                 mate          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
              minimax          +0.0%      0.0%     -0.0%     +0.0%     -0.0%
              mkhprog          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
           multiplier          +0.0%      0.0%      0.0%     +0.0%     -0.0%
               n-body          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
             nucleic2          +0.0%      0.0%     +0.0%     +0.0%     -0.0%
                 para          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
            paraffins          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
               parser          +0.1%      0.0%     +0.4%     -1.7%     -0.0%
              parstof          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  pic          +0.0%      0.0%     +0.0%      0.0%     -0.0%
             pidigits          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
                power          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
               pretty          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
               primes          +0.0%      0.0%     +0.0%      0.0%      0.0%
            primetest          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
               prolog          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
               puzzle          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
               queens          +0.0%      0.0%      0.0%     +0.0%     +0.0%
              reptile          +0.0%      0.0%     +0.0%     +0.0%      0.0%
      reverse-complem          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
              rewrite          +0.0%      0.0%     +0.0%      0.0%     -0.0%
                 rfib          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
                  rsa          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
                  scc          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
                sched          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
                  scs          +0.0%      0.0%     +0.0%     +0.0%      0.0%
               simple          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
                solid          +0.0%      0.0%     +0.0%     +0.0%      0.0%
              sorting          +0.0%      0.0%     +0.0%     -0.0%      0.0%
        spectral-norm          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
               sphere          +0.0%      0.0%     +0.0%     -1.0%      0.0%
               symalg          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
                  tak          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
            transform          +0.0%      0.0%     +0.4%     -1.3%     +0.0%
             treejoin          +0.0%      0.0%     +0.0%     -0.0%      0.0%
            typecheck          +0.0%      0.0%     -0.0%     +0.0%      0.0%
              veritas          +0.0%      0.0%     +0.0%     -0.1%     +0.0%
                 wang          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
            wave4main          +0.0%      0.0%     +0.0%      0.0%     -0.0%
         wheel-sieve1          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
         wheel-sieve2          +0.0%      0.0%     +0.0%     +0.0%      0.0%
                 x2n1          +0.0%      0.0%     +0.0%     +0.0%      0.0%
      --------------------------------------------------------------------------------
                  Min          +0.0%      0.0%     -0.0%     -6.1%     -0.0%
                  Max          +0.1%      0.0%     +1.2%     +0.0%     +0.0%
       Geometric Mean          +0.0%     -0.0%     +0.0%     -0.1%     -0.0%
      
      NoFib GC Results
      ================
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs    Instrs     Reads    Writes
      --------------------------------------------------------------------------------
              circsim          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
          constraints          +0.0%      0.0%     -0.0%      0.0%     -0.0%
             fibheaps          +0.0%      0.0%      0.0%     -0.0%     -0.0%
               fulsom          +0.0%      0.0%      0.0%     -0.6%     -0.0%
             gc_bench          +0.0%      0.0%      0.0%      0.0%     -0.0%
                 hash          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 lcss          +0.0%      0.0%      0.0%     -0.0%      0.0%
            mutstore1          +0.0%      0.0%      0.0%     -0.0%     -0.0%
            mutstore2          +0.0%      0.0%     +0.0%     -0.0%     -0.0%
                power          +0.0%      0.0%     -0.0%      0.0%     -0.0%
           spellcheck          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
      --------------------------------------------------------------------------------
                  Min          +0.0%      0.0%     -0.0%     -0.6%     -0.0%
                  Max          +0.0%      0.0%     +0.0%      0.0%      0.0%
       Geometric Mean          +0.0%     +0.0%     +0.0%     -0.1%     +0.0%
      
      Fixes #14373
      
      These performance regressions appear to be a fluke in CI. See the
      discussion in !1742 for details.
      
      Metric Increase:
          T6048
          T12234
          T12425
          Naperian
          T12150
          T5837
          T13035
      9897e8c8
  14. 05 Dec, 2019 1 commit
    • Vladislav Zavialov's avatar
      Pretty-printing of the * kind · 3354c68e
      Vladislav Zavialov authored
      Before this patch, GHC always printed the * kind unparenthesized.
      
      This led to two issues:
      
      1. Sometimes GHC printed invalid or incorrect code.
         For example, GHC would print:  type F @*   x = x
               when it meant to print:  type F @(*) x = x
         In the former case, instead of a kind application we were getting a
         type operator (@*).
      
      2. Sometimes GHC printed kinds that were correct but hard to read.
         Should  Either * Int  be read as  Either (*) Int
                                    or as  (*) Either Int  ?
         This depends on whether -XStarIsType is enabled, but it would be
         easier if we didn't have to check for the flag when reading the code.
      
      We can solve both problems by assigning (*) a different precedence. Note
      that Haskell98 kinds are not affected:
      
        ((* -> *) -> *) -> *  does NOT become  (((*) -> (*)) -> (*)) -> (*)
      
      The parentheses are added when (*) is used in a function argument
      position:
      
         F * * *   becomes  F (*) (*) (*)
         F A * B   becomes  F A (*) B
         Proxy *   becomes  Proxy (*)
         a * -> *  becomes  a (*) -> *
      3354c68e
  15. 03 Dec, 2019 1 commit
  16. 02 Dec, 2019 1 commit
  17. 30 Nov, 2019 1 commit
  18. 28 Nov, 2019 2 commits
    • Vladislav Zavialov's avatar
      Factor out HsSCC/HsCoreAnn/HsTickPragma into HsPragE · 6985e0fc
      Vladislav Zavialov authored
      This is a refactoring with no user-visible changes (except for GHC API
      users). Consider the HsExpr constructors that correspond to user-written
      pragmas:
      
        HsSCC         representing  {-# SCC ... #-}
        HsCoreAnn     representing  {-# CORE ... #-}
        HsTickPragma  representing  {-# GENERATED ... #-}
      
      We can factor them out into a separate datatype, HsPragE. It makes the
      code a bit tidier, especially in the parser.
      
      Before this patch:
      
        hpc_annot :: { Located ( (([AddAnn],SourceText),(StringLiteral,(Int,Int),(Int,Int))),
                                 ((SourceText,SourceText),(SourceText,SourceText))
                               ) }
      
      After this patch:
      
        prag_hpc :: { Located ([AddAnn], HsPragE GhcPs) }
      6985e0fc
    • Brian Wignall's avatar
      3748ba3a
  19. 27 Nov, 2019 2 commits
    • Vladislav Zavialov's avatar
      Whitespace-sensitive bang patterns (#1087, #17162) · 8168b42a
      Vladislav Zavialov authored
      This patch implements a part of GHC Proposal #229 that covers five
      operators:
      
      * the bang operator (!)
      * the tilde operator (~)
      * the at operator (@)
      * the dollar operator ($)
      * the double dollar operator ($$)
      
      Based on surrounding whitespace, these operators are disambiguated into
      bang patterns, lazy patterns, strictness annotations, type
      applications, splices, and typed splices.
      
      This patch doesn't cover the (-) operator or the -Woperator-whitespace
      warning, which are left as future work.
      8168b42a
    • Sebastian Graf's avatar
      Make warnings for TH splices opt-in · 5a08f7d4
      Sebastian Graf authored
      In #17270 we have the pattern-match checker emit incorrect warnings. The
      reason for that behavior is ultimately an inconsistency in whether we
      treat TH splices as written by the user (`FromSource :: Origin`) or as
      generated code (`Generated`). This was first reported in #14838.
      
      The current solution is to TH splices as `Generated` by default and only
      treat them as `FromSource` when the user requests so
      (-fenable-th-splice-warnings). There are multiple reasons for opt-in
      rather than opt-out:
      
        * It's not clear that the user that compiles a splice is the author of the code
          that produces the warning. Think of the situation where she just splices in
          code from a third-party library that produces incomplete pattern matches.
          In this scenario, the user isn't even able to fix that warning.
        * Gathering information for producing the warnings (pattern-match check
          warnings in particular) is costly. There's no point in doing so if the user
          is not interested in those warnings.
      
      Fixes #17270, but not #14838, because the proper solution needs a GHC
      proposal extending the TH AST syntax.
      5a08f7d4
  20. 25 Nov, 2019 1 commit
  21. 20 Nov, 2019 1 commit
  22. 17 Nov, 2019 2 commits
  23. 13 Nov, 2019 2 commits
    • Ryan Scott's avatar
      Print name prefixly in the Outputable instance for StandaloneKindSig · 9a939a6c
      Ryan Scott authored
      Issue #17461 was occurring because the `Outputable` instance for
      standalone kind signatures was simply calling `ppr` on the name in
      the kind signature, which does not add parentheses to infix names.
      The solution is simple: use `pprPrefixOcc` instead.
      
      Fixes #17461.
      9a939a6c
    • Ben Gamari's avatar
      Ensure that coreView/tcView are able to inline · 2d4f9ad8
      Ben Gamari authored
      Previously an import cycle between Type and TyCoRep meant that several
      functions in TyCoRep ended up SOURCE import coreView. This is quite
      unfortunate as coreView is intended to be fused into a larger pattern
      match and not incur an extra call.
      
      Fix this with a bit of restructuring:
      
       * Move the functions in `TyCoRep` which depend upon things in `Type`
         into `Type`
       * Fold contents of `Kind` into `Type` and turn `Kind` into a simple
         wrapper re-exporting kind-ish things from `Type`
       * Clean up the redundant imports that popped up as a result
      
      Closes #17441.
      
      Metric Decrease:
          T4334
      2d4f9ad8
  24. 10 Nov, 2019 1 commit
  25. 07 Nov, 2019 1 commit
    • Ryan Scott's avatar
      Clean up TH's treatment of unary tuples (or, #16881 part two) · 708c60aa
      Ryan Scott authored
      !1906 left some loose ends in regards to Template Haskell's treatment
      of unary tuples. This patch ends to tie up those loose ends:
      
      * In addition to having `TupleT 1` produce unary tuples, `TupE [exp]`
        and `TupP [pat]` also now produce unary tuples.
      * I have added various special cases in GHC's pretty-printers to
        ensure that explicit 1-tuples are printed using the `Unit` type.
        See `testsuite/tests/th/T17380`.
      * The GHC 8.10.1 release notes entry has been tidied up a little.
      
      Fixes #16881. Fixes #17371. Fixes #17380.
      708c60aa
  26. 05 Nov, 2019 1 commit
    • Sebastian Graf's avatar
      Check EmptyCase by simply adding a non-void constraint · 1593debf
      Sebastian Graf authored
      We can handle non-void constraints since !1733, so we can now express
      the strictness of `-XEmptyCase` just by adding a non-void constraint
      to the initial Uncovered set.
      
      For `case x of {}` we thus check that the Uncovered set `{ x | x /~ ⊥ }`
      is non-empty. This is conceptually simpler than the plan outlined in
       #17376, because it talks to the oracle directly.
      
      In order for this patch to pass the testsuite, I had to fix handling of
      newtypes in the pattern-match checker (#17248).
      
      Since we use a different code path (well, the main code path) for
      `-XEmptyCase` now, we apparently also handle #13717 correctly.
      There's also some dead code that we can get rid off now.
      
      `provideEvidence` has been updated to provide output more in line with
      the old logic, which used `inhabitationCandidates` under the hood.
      
      A consequence of the shift away from the `UncoveredPatterns` type is
      that we don't report reduced type families for empty case matches,
      because the pretty printer is pure and only knows the match variable's
      type.
      
      Fixes #13717, #17248, #17386
      1593debf
  27. 03 Nov, 2019 1 commit
    • Sebastian Graf's avatar
      Separate `LPat` from `Pat` on the type-level · 182b1199
      Sebastian Graf authored
      Since the Trees That Grow effort started, we had `type LPat = Pat`.
      This is so that `SrcLoc`s would only be annotated in GHC's AST, which is
      the reason why all GHC passes use the extension constructor `XPat` to
      attach source locations. See #15495 for the design discussion behind
      that.
      
      But now suddenly there are `XPat`s everywhere!
      There are several functions which dont't cope with `XPat`s by either
      crashing (`hsPatType`) or simply returning incorrect results
      (`collectEvVarsPat`).
      
      This issue was raised in #17330. I also came up with a rather clean and
      type-safe solution to the problem: We define
      
      ```haskell
      type family XRec p (f :: * -> *) = r | r -> p f
      type instance XRec (GhcPass p) f = Located (f (GhcPass p))
      type instance XRec TH          f =          f p
      type LPat p = XRec p Pat
      ```
      
      This is a rather modular embedding of the old "ping-pong" style, while
      we only pay for the `Located` wrapper within GHC. No ping-ponging in
      a potential Template Haskell AST, for example. Yet, we miss no case
      where we should've handled a `SrcLoc`: `hsPatType` and
      `collectEvVarsPat` are not callable at an `LPat`.
      
      Also, this gets rid of one indirection in `Located` variants:
      Previously, we'd have to go through `XPat` and `Located` to get from
      `LPat` to the wrapped `Pat`. Now it's just `Located` again.
      
      Thus we fix #17330.
      182b1199
  28. 01 Nov, 2019 1 commit