1. 21 Feb, 2020 1 commit
    • Simon Peyton Jones's avatar
      Re-implement unsafe coercions in terms of unsafe equality proofs · 74ad75e8
      Simon Peyton Jones authored
      (Commit message written by Omer, most of the code is written by Simon
      and Richard)
      
      See Note [Implementing unsafeCoerce] for how unsafe equality proofs and
      the new unsafeCoerce# are implemented.
      
      New notes added:
      
      - [Checking for levity polymorphism] in CoreLint.hs
      - [Implementing unsafeCoerce] in base/Unsafe/Coerce.hs
      - [Patching magic definitions] in Desugar.hs
      - [Wiring in unsafeCoerce#] in Desugar.hs
      
      Only breaking change in this patch is unsafeCoerce# is not exported from
      GHC.Exts, instead of GHC.Prim.
      
      Fixes #17443
      Fixes #16893
      
      NoFib
      -----
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs    Instrs     Reads    Writes
      --------------------------------------------------------------------------------
                   CS          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  CSD          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                   FS          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                    S          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                   VS          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  VSD          -0.1%      0.0%     -0.0%     -0.0%     -0.1%
                  VSM          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 anna          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 ansi          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 atom          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               awards          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               banner          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           bernouilli          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         binary-trees          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                boyer          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               boyer2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 bspt          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            cacheprof          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             calendar          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             cichelli          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              circsim          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             clausify          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        comp_lab_zift          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             compress          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            compress2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          constraints          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         cryptarithm1          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         cryptarithm2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  cse          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         digits-of-e1          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         digits-of-e2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               dom-lt          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                eliza          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                event          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          exact-reals          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               exp3_8          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               expert          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       fannkuch-redux          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                fasta          -0.1%      0.0%     -0.5%     -0.3%     -0.4%
                  fem          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  fft          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 fft2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             fibheaps          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 fish          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                fluid          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               fulsom          -0.1%      0.0%     +0.0%     +0.0%     +0.0%
               gamteb          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  gcd          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          gen_regexps          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               genfft          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                   gg          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 grep          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               hidden          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  hpg          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  ida          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                infer          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              integer          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            integrate          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         k-nucleotide          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                kahan          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              knights          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               lambda          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           last-piece          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 lcss          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 life          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 lift          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               linear          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            listcompr          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             listcopy          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             maillist          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               mandel          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              mandel2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 mate          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              minimax          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              mkhprog          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           multiplier          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               n-body          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             nucleic2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 para          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            paraffins          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               parser          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              parstof          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  pic          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             pidigits          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                power          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               pretty          -0.1%      0.0%     -0.1%     -0.1%     -0.1%
               primes          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            primetest          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               prolog          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               puzzle          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               queens          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              reptile          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      reverse-complem          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              rewrite          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 rfib          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  rsa          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  scc          -0.1%      0.0%     -0.1%     -0.1%     -0.1%
                sched          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  scs          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               simple          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                solid          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              sorting          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        spectral-norm          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               sphere          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               symalg          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  tak          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            transform          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             treejoin          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            typecheck          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              veritas          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 wang          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            wave4main          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         wheel-sieve1          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         wheel-sieve2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 x2n1          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      --------------------------------------------------------------------------------
                  Min          -0.1%      0.0%     -0.5%     -0.3%     -0.4%
                  Max          -0.0%      0.0%     +0.0%     +0.0%     +0.0%
       Geometric Mean          -0.1%     -0.0%     -0.0%     -0.0%     -0.0%
      
      Test changes
      ------------
      
      - break006 is marked as broken, see #17833
      - The compiler allocates less when building T14683 (an unsafeCoerce#-
        heavy happy-generated code) on 64-platforms. Allocates more on 32-bit
        platforms.
      - Rest of the increases are tiny amounts (still enough to pass the
        threshold) in micro-benchmarks. I briefly looked at each one in a
        profiling build: most of the increased allocations seem to be because
        of random changes in the generated code.
      
      Metric Decrease:
          T14683
      
      Metric Increase:
          T12150
          T12234
          T12425
          T13035
          T14683
          T5837
          T6048
      Co-Authored-By: Richard Eisenberg's avatarRichard Eisenberg <rae@cs.brynmawr.edu>
      Co-Authored-By: Ömer Sinan Ağacan's avatarÖmer Sinan Ağacan <omeragacan@gmail.com>
      74ad75e8
  2. 19 Feb, 2020 4 commits
  3. 16 Feb, 2020 1 commit
  4. 14 Feb, 2020 5 commits
  5. 13 Feb, 2020 1 commit
  6. 12 Feb, 2020 4 commits
  7. 11 Feb, 2020 5 commits
    • Matthew Pickering's avatar
      TemplateHaskellQuotes: Allow nested splices · 82023524
      Matthew Pickering authored
      There is no issue with nested splices as they do not require any compile
      time code execution. All execution is delayed until the top-level
      splice.
      82023524
    • Simon Peyton Jones's avatar
      Notes only: telescopes · d8d73d77
      Simon Peyton Jones authored
      This documentation-only patch fixes #17793
      d8d73d77
    • Sylvain Henry's avatar
      Add arithmetic exception primops (#14664) · aba51b65
      Sylvain Henry authored
      aba51b65
    • Richard Eisenberg's avatar
      Do not create nested quantified constraints · de32beff
      Richard Eisenberg authored
      Previously, we would accidentally make constraints like
      forall a. C a => forall b. D b => E a b c as we traversed
      superclasses. No longer!
      
      This patch also expands Note [Eagerly expand given superclasses]
      to work over quantified constraints; necessary for T16502b.
      
      Close #17202 and #16502.
      
      test cases: typecheck/should_compile/T{17202,16502{,b}}
      de32beff
    • Sebastian Graf's avatar
      Fix long distance info for record updates · f3e737bb
      Sebastian Graf authored
      For record updates where the `record_expr` is a variable, as in #17783:
      
      ```hs
      data PartialRec = No
                      | Yes { a :: Int, b :: Bool }
      update No = No
      update r@(Yes {}) = r { b = False }
      ```
      
      We should make use of long distance info in
      `-Wincomplete-record-updates` checking. But the call to `matchWrapper`
      in the `RecUpd` case didn't specify a scrutinee expression, which would
      correspond to the `record_expr` `r` here. That is fixed now.
      
      Fixes #17783.
      f3e737bb
  8. 09 Feb, 2020 3 commits
    • Andreas Klebinger's avatar
      Fix -ddump-stg-final. · b2e18e26
      Andreas Klebinger authored
      Once again make sure this dumps the STG used for codegen.
      b2e18e26
    • Roland Senn's avatar
      Fix #14628: Panic (No skolem Info) in GHCi · 82f9be8c
      Roland Senn authored
      This patch implements the [sugggestion from Simon (PJ)](ghc/ghc#14628 (comment 146559)):
      - Make `TcErrors.getSkolemInfo` return a `SkolemInfo` rather than an `Implication`.
      - If `getSkolemInfo` gets `RuntimeUnk`s, just return a new data constructor in `SkolemInfo`, called `RuntimeUnkSkol`.
      - In `TcErrors.pprSkols` print something sensible for a `RuntimeUnkSkol`.
      
      The `getSkolemInfo` function paniced while formating suggestions to add type annotations (subfunction `suggestAddSig`)
      to a *"Couldn't match type ‘x’ with ‘y’"* error message.
      The `getSkolemInfo` function didn't find any Implication value and paniced.
      With this patch the `getSkolemInfo` function does no longer panic, if it finds `RuntimeUnkSkol`s.
      
      As the panic occured while processing an error message, we don't need to implement any new error message!
      82f9be8c
    • Arnaud Spiwack's avatar
      Fix an outdated note link · a906595f
      Arnaud Spiwack authored
      This link appears to have been forgotten in
      0dad81ca .
      a906595f
  9. 08 Feb, 2020 8 commits
  10. 06 Feb, 2020 8 commits
    • Simon Peyton Jones's avatar
      Comments only · 7c122851
      Simon Peyton Jones authored
      7c122851
    • Simon Peyton Jones's avatar
      Use foldTyCo for exactTyCoVarsOfType · 5541b87c
      Simon Peyton Jones authored
      This entailed
      
      * Adding a tcf_view field to TyCoFolder
      
      * Moving exactTyCoVarsOtType to TcType.  It properly belongs
        there, since only the typechecker calls this function. But
        it also means that we can "see" and inline tcView.
      
      Metric Decrease:
        T14683
      5541b87c
    • Simon Peyton Jones's avatar
      Use foldTyCo for coVarsOfType · 9ca5c88e
      Simon Peyton Jones authored
      9ca5c88e
    • Simon Peyton Jones's avatar
      Simplify closeOverKinds · 0e59afd6
      Simon Peyton Jones authored
      0e59afd6
    • Simon Peyton Jones's avatar
      Use foldTyCo for noFreeVarsOfType · 01a1f4fb
      Simon Peyton Jones authored
      01a1f4fb
    • Simon Peyton Jones's avatar
      Reform the free variable finders for types · ed2f0e5c
      Simon Peyton Jones authored
      This patch delivers on (much of) #17509.
      
      * Introduces the shallow vs deep free variable distinction
      
      * Introduce TyCoRep.foldType,
          foldType :: Monoid a => TyCoFolder env a
                               -> env -> Type -> a
        and use it in the free variable finders.
      
      * Substitution in TyCoSubst
         * ASSERTs are on for checkValidSubst
         * checkValidSubst uses shallowTyCoVarsOfTypes etc
      
      Quite a few things still to do
      
      * We could use foldType in lots of other places
      
      * We could use mapType for substitution.  (Check that we get
        good code!)
      
      * Some (but not yet all) clients of substitution can now
        save time by using shallowTyCoVarsOfTypes
      
      * All calls to tyCoVarsOfTypes should be inspected; most of
        them should be shallow.  Maybe.
      
      * Currently shallowTyCoVarsOfTypes still returns
        unification variables, but not CoVarHoles.
        Reason: we need to return unification variables
        in some of the calls in TcSimplify, eg when promoting.
      
      * We should do the same thing for tyCoFVsOfTypes, which is
        currently unchanged.
      
      * tyCoFVsOfTypes returns CoVarHoles, because of the
        use in TcSimplify.mkResidualConstraints.  See
        Note [Emitting the residual implication in simplifyInfer]
      
      * #17509 talks about "relevant" variables too.
      ed2f0e5c
    • Ben Gamari's avatar
      Move closeOverKinds and friends to TyCoFVs · c4e6b35d
      Ben Gamari authored
      c4e6b35d
    • Ben Gamari's avatar
      VarSet: Introduce nonDetFoldVarSet · 29b72c00
      Ben Gamari authored
      29b72c00