Skip to content
Snippets Groups Projects
  1. Dec 18, 2020
    • Ryan Scott's avatar
      Use HsOuterExplicit in instance sigs in deriving-generated code · 7a93435b
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      Issue #18914 revealed that `GeneralizedNewtypeDeriving` would generate code
      that mentions unbound type variables, which is dangerously fragile. The
      problem (and fix) is described in the new `Wrinkle: Use HsOuterExplicit`
      in `Note [GND and QuantifiedConstraints]`. The gist of it: make sure to
      put the top-level `forall`s in `deriving`-generated instance signatures in an
      `HsOuterExplicit` to ensure that they scope over the bodies of methods
      correctly. A side effect of this process is that it will expand any type
      synonyms in the instance signature, which will surface any `forall`s that
      are hidden underneath type synonyms (such as in the test case for #18914).
      
      While I was in town, I also performed some maintenance on `NewHsTypeX`, which
      powers `GeneralizedNewtypeDeriving`:
      
      * I renamed `NewHsTypeX` to `HsCoreTy`, which more accurately describes its
        intended purpose (#15706). I also made `HsCoreTy` a type synonym instead of
        a newtype, as making it a distinct data type wasn't buying us much.
      * To make sure that mistakes similar to #18914 do not occur later, I added an
        additional validity check when renaming `HsCoreTy`s that complains if an
        `HsCoreTy`s contains an out-of-scope type variable. See the new
        `Note [Renaming HsCoreTys]` in `GHC.Rename.HsType` for the details.
      
      Fixes #15706. Fixes #18914. Bumps the `haddock` submodule.
      7a93435b
  2. Dec 17, 2020
    • Sylvain Henry's avatar
      Fix project version for ProjectVersionMunged (fix #19058) · 659fcb14
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      659fcb14
    • Richard Eisenberg's avatar
      Unfortunate dirty hack to overcome #18998. · df7c7faa
      Richard Eisenberg authored and Marge Bot's avatar Marge Bot committed
      See commentary in tcCheckUsage.
      
      Close #18998.
      
      Test case: typecheck/should_compile/T18998
      df7c7faa
    • Tom Ellis's avatar
      submodule update: containers and stm · cf8ab4a6
      Tom Ellis authored and Marge Bot's avatar Marge Bot committed
      Needed for ghc/ghc#15656 as it
      stops the packages triggering incomplete-uni-patterns and
      incomplete-record-updates
      cf8ab4a6
    • Ryan Scott's avatar
      Reject dodgy scoping in associated family instance RHSes · b1178cbc
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      Commit e63518f5 tried to push all of the logic
      of detecting out-of-scope type variables on the RHSes of associated type family
      instances to `GHC.Tc.Validity` by deleting a similar check in the renamer.
      Unfortunately, this commit went a little too far, as there are some corner
      cases that `GHC.Tc.Validity` doesn't detect. Consider this example:
      
      ```hs
      class C a where
        data D a
      
      instance forall a. C Int where
        data instance D Int = MkD a
      ```
      
      If this program isn't rejected by the time it reaches the typechecker, then
      GHC will believe the `a` in `MkD a` is existentially quantified and accept it.
      This is almost surely not what the user wants! The simplest way to reject
      programs like this is to restore the old validity check in the renamer
      (search for `improperly_scoped` in `rnFamEqn`).
      
      Note that this is technically a breaking change, since the program in the
      `polykinds/T9574` test case (which previously compiled) will now be rejected:
      
      ```hs
      instance Funct ('KProxy :: KProxy o) where
          type Codomain 'KProxy = NatTr (Proxy :: o -> *)
      ```
      
      This is because the `o` on the RHS will now be rejected for being out of scope.
      Luckily, this is simple to repair:
      
      ```hs
      instance Funct ('KProxy :: KProxy o) where
          type Codomain ('KProxy @o) = NatTr (Proxy :: o -> *)
      ```
      
      All of the discussion is now a part of the revamped
      `Note [Renaming associated types]` in `GHC.Rename.Module`.
      
      A different design would be to make associated type family instances have
      completely separate scoping from the parent instance declaration, much like
      how associated type family default declarations work today. See the discussion
      beginning at #18021 (comment 265729) for
      more on this point. This, however, would break even more programs that are
      accepted today and likely warrants a GHC proposal before going forward. In the
      meantime, this patch fixes the issue described in #18021 in the least invasive
      way possible. There are programs that are accepted today that will no longer
      be accepted after this patch, but they are arguably pathological programs, and
      they are simple to repair.
      
      Fixes #18021.
      b1178cbc
    • Alex D's avatar
      Force module recompilation if '*' prefix was used to load modules in ghci (#8042) · 09f28390
      Alex D authored and Marge Bot's avatar Marge Bot committed
      Usually pre-compiled code is preferred to be loaded in ghci if available, which means
      that if we try to load module with '*' prefix and compilation artifacts are available
      on disc (.o and .hi files) or the source code was untouched, the driver would think
      no recompilation is required. Therefore, we need to force recompilation so that desired
      byte-code is generated and loaded. Forcing in this case should be ok, since this is what
      happens for interpreted code anyways when reloading modules.
      09f28390
    • davide's avatar
      User guide minor typo · 80df2edd
      davide authored and Marge Bot's avatar Marge Bot committed
      [ci skip]
      80df2edd
  3. Dec 16, 2020
  4. Dec 15, 2020
  5. Dec 14, 2020
    • Andrew Martin's avatar
      Implement BoxedRep proposal · 6c2eb223
      Andrew Martin authored and Ben Gamari's avatar Ben Gamari committed
      This implements the BoxedRep proposal, refacoring the `RuntimeRep`
      hierarchy from:
      
      ```haskell
      data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ...
      ```
      
      to
      
      ```haskell
      data RuntimeRep = BoxedRep Levity | ...
      data Levity = Lifted | Unlifted
      ```
      
      Closes #17526.
      6c2eb223
    • Ben Gamari's avatar
      Optimise nullary type constructor usage · dad87210
      Ben Gamari authored
      During the compilation of programs GHC very frequently deals with
      the `Type` type, which is a synonym of `TYPE 'LiftedRep`. This patch
      teaches GHC to avoid expanding the `Type` synonym (and other nullary
      type synonyms) during type comparisons, saving a good amount of work.
      This optimisation is described in `Note [Comparing nullary type
      synonyms]`.
      
      To maximize the impact of this optimisation, we introduce a few
      special-cases to reduce `TYPE 'LiftedRep` to `Type`. See
      `Note [Prefer Type over TYPE 'LiftedPtrRep]`.
      
      Closes #17958.
      
      Metric Decrease:
         T18698b
         T1969
         T12227
         T12545
         T12707
         T14683
         T3064
         T5631
         T5642
         T9020
         T9630
         T9872a
         T13035
         haddock.Cabal
         haddock.base
      dad87210
    • Andreas Klebinger's avatar
      Optimize dumping of consecutive whitespace. · af855ac1
      Andreas Klebinger authored
      The naive way of putting out n characters of indent would be something
      like `hPutStr hdl (replicate n ' ')`. However this is quite inefficient
      as we allocate an absurd number of strings consisting of simply spaces
      as we don't cache them.
      
      To improve on this we now track if we can simply write ascii spaces via
      hPutBuf instead. This is the case when running with -ddump-to-file where
      we force the encoding to be UTF8.
      
      This avoids both the cost of going through encoding as well as avoiding
      allocation churn from all the white space. Instead we simply use hPutBuf
      on a preallocated unlifted string.
      
      When dumping stg like this:
      
      > nofib/spectral/simple/Main.hs -fforce-recomp -ddump-stg-final -ddump-to-file -c +RTS -s
      
      Allocations went from 1,778 MB to 1,702MB. About a 4% reduction of
      allocation! I did not measure the difference in runtime but expect it
      to be similar.
      
      Bumps the haddock submodule since the interface of GHC's Pretty
      slightly changed.
      
      -------------------------
      Metric Decrease:
          T12227
      -------------------------
      af855ac1
    • Sylvain Henry's avatar
      Move Unit related fields from DynFlags to HscEnv · d0e8c10d
      Sylvain Henry authored
      The unit database cache, the home unit and the unit state were stored in
      DynFlags while they ought to be stored in the compiler session state
      (HscEnv). This patch fixes this.
      
      It introduces a new UnitEnv type that should be used in the future to
      handle separate unit environments (especially host vs target units).
      
      Related to #17957
      
      Bump haddock submodule
      d0e8c10d
    • Ben Gamari's avatar
      Revert "Optimise nullary type constructor usage" · 92377c27
      Ben Gamari authored
      This was inadvertently merged.
      
      This reverts commit 7e9debd4.
      92377c27
    • Ben Gamari's avatar
      Optimise nullary type constructor usage · 7e9debd4
      Ben Gamari authored
      During the compilation of programs GHC very frequently deals with
      the `Type` type, which is a synonym of `TYPE 'LiftedRep`. This patch
      teaches GHC to avoid expanding the `Type` synonym (and other nullary
      type synonyms) during type comparisons, saving a good amount of work.
      This optimisation is described in `Note [Comparing nullary type
      synonyms]`.
      
      To maximize the impact of this optimisation, we introduce a few
      special-cases to reduce `TYPE 'LiftedRep` to `Type`. See
      `Note [Prefer Type over TYPE 'LiftedPtrRep]`.
      
      Closes #17958.
      
      Metric Decrease:
         T18698b
         T1969
         T12227
         T12545
         T12707
         T14683
         T3064
         T5631
         T5642
         T9020
         T9630
         T9872a
         T13035
         haddock.Cabal
         haddock.base
      7e9debd4
    • cgibbard's avatar
      Implement type applications in patterns · c696bb2f
      cgibbard authored and Ben Gamari's avatar Ben Gamari committed
      The haddock submodule is also updated so that it understands the changes
      to patterns.
      c696bb2f
  6. Dec 13, 2020
  7. Dec 12, 2020
  8. Dec 11, 2020
Loading