1. 15 Apr, 2016 1 commit
  2. 11 Apr, 2016 2 commits
    • Ryan Scott's avatar
      Deriving Functor-like classes should unify kind variables · 9c48d8a0
      Ryan Scott authored and Ben Gamari's avatar Ben Gamari committed
      While the deriving machinery always unifies the kind of the typeclass
      argument with the kind of the datatype, this proves not to be sufficient
      to produce well kinded instances for some poly-kinded datatypes. For
      newtype Compose (f :: k2 -> *) (g :: k1 -> k2) (a :: k1)
        = Compose (f (g a)) deriving Functor
      would fail because only `k1` would get unified with `*`, causing the
      ill kinded instance to be generated:
      instance (Functor (f :: k2 -> *), Functor (g :: * -> k2)) =>
        Functor (Compose f g) where ...
      To prevent this, we need to take the subtypes and unify their kinds with
      `* -> *`.
      Fixes #10524 for good.
      Test Plan: ./validate
      Reviewers: simonpj, hvr, austin, bgamari
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2097
      GHC Trac Issues: #10524, #10561
      (cherry picked from commit aadde2b9)
    • duairc's avatar
      Added (more) missing instances for Identity and Const · 7b8beba7
      duairc authored and Ben Gamari's avatar Ben Gamari committed
        * `Identity` and `Const` now have `Num`, `Real`, `Integral`,
          `Fractional`, `Floating`, `RealFrac` and `RealFloat` instances
        * `Identity` and `Const` now have `Bits` and `FiniteBits` instances
        * `Identity` and `Const` now have `IsString` instances
      Reviewers: RyanGlScott, austin, hvr, bgamari, ekmett
      Reviewed By: ekmett
      Subscribers: nomeata, ekmett, RyanGlScott, thomie
      Differential Revision: https://phabricator.haskell.org/D2079
      GHC Trac Issues: #11790
      (cherry picked from commit 8b57cac5)
  3. 10 Apr, 2016 4 commits
    • Tamar Christina's avatar
      Change runtime linker to perform lazy loading of symbols/sections · 068d9273
      Tamar Christina authored and Ben Gamari's avatar Ben Gamari committed
      The Runtime Linker is currently eagerly loading all object files on all
      platforms which do not use the system linker for `GHCi`.
      The problem with this approach is that it requires all symbols to be
      found.  Even those of functions never used/called. This makes the number
      of libraries required to link things like `mingwex` quite high.
      To work around this the `rts` was relying on a trick. It itself was
      compiled with `MingW64-w`'s `GCC`. So it was already linked against
      `mingwex`.  As such, it re-exported the symbols from itself.
      While this worked it made it impossible to link against `mingwex` in
      user libraries. And with this means no `C99` code could ever run in
      `GHCi` on Windows without having the required symbols re-exported from
      the rts.
      Consequently this rules out a large number of packages on Windows.
      SDL2, HMatrix etc.
      After talking with @rwbarton I have taken the approach of loading entire
      object files when a symbol is needed instead of doing the dependency
      tracking on a per symbol basis. This is a lot less fragile and a lot
      less complicated to implement.
      The changes come down to the following steps:
      1) modify the linker to and introduce a new state for ObjectCode:
         `Needed`.  A Needed object is one that is required for the linking to
         succeed.  The initial set consists of all Object files passed as
         arguments to the link.
      2) Change `ObjectCode`'s to be indexed but not initialized or resolved.
         This means we know where we would load the symbols,
         but haven't actually done so.
      3) Mark any `ObjectCode` belonging to `.o` passed as argument
         as required: ObjectState `NEEDED`.
      4) During `Resolve` object calls, mark all `ObjectCode`
         containing the required symbols as `NEEDED`
      5) During `lookupSymbol` lookups, (which is called from `linkExpr`
         and `linkDecl` in `GHCI.hs`) is the symbol is in a not-yet-loaded
         `ObjectCode` then load the `ObjectCode` on demand and return the
         address of the symbol. Otherwise produce an unresolved symbols error
         as expected.
      6) On `unloadObj` we then change the state of the object and remove
         it's symbols from the `reqSymHash` table so it can be reloaded.
      This change affects all platforms and OSes which use the runtime linker.
      It seems there are no real perf tests for `GHCi`, but performance
      shouldn't be impacted much. We gain a lot of time not loading all `obj`
      files, and we lose some time in `lookupSymbol` when we're finding
      sections that have to be loaded. The actual finding itself is O(1)
      (Assuming the hashtnl is perfect)
      It also consumes slighly more memory as instead of storing just the
      address of a symbol I also store some other information, like if the
      symbol is weak or not.
      This change will break any packages relying on renamed POSIX functions
      that were re-named and re-exported by the rts. Any packages following
      the proper naming for functions as found on MSDN will work fine.
      Test Plan: ./validate on all platforms which use the Runtime linker.
      Reviewers: thomie, rwbarton, simonmar, erikd, bgamari, austin, hvr
      Reviewed By: erikd
      Subscribers: kgardas, gridaphobe, RyanGlScott, simonmar,
                   rwbarton, #ghc_windows_task_force
      Differential Revision: https://phabricator.haskell.org/D1805
      GHC Trac Issues: #11223
      (cherry picked from commit 90538d86)
    • Ben Gamari's avatar
      base: Fix "since" annotation on GHC.ExecutionStack · 7f27f7a2
      Ben Gamari authored
      I have no idea where "4.11" came from.
      (cherry picked from commit ad532ded)
    • Chris Martin's avatar
      Add doc to (<=<) comparing its type to (.) · a7cb9cf7
      Chris Martin authored and Ben Gamari's avatar Ben Gamari committed
      This is another documentation addition similar to D1989, this time
      comparing the type of the Kleisli composition operator (<=<) to that
      of plain function composition (.).
      Reviewers: hvr, austin, bgamari
      Reviewed By: bgamari
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D2100
      (cherry picked from commit 90d66ded)
    • Michael Snoyman's avatar
      Provide an optimized replicateM_ implementation #11795 · 7c6bc78f
      Michael Snoyman authored and Ben Gamari's avatar Ben Gamari committed
      In my testing, the worker/wrapper transformation applied here
      significantly decreases the number of allocations performed when using
      replicateM_. Additionally, this version of the function behaves
      correctly for negative numbers (namely, it will behave the same as
      replicateM_ 0, which is what previous versions of base have done).
      Reviewers: bgamari, simonpj, hvr, austin
      Reviewed By: bgamari, simonpj, austin
      Subscribers: nomeata, simonpj, mpickering, thomie
      Differential Revision: https://phabricator.haskell.org/D2086
      GHC Trac Issues: #11795
      (cherry picked from commit c4a7520e)
  4. 04 Apr, 2016 1 commit
    • Eric Seidel's avatar
      Don't infer CallStacks · 773e81ba
      Eric Seidel authored and Ben Gamari's avatar Ben Gamari committed
      We originally wanted CallStacks to be opt-in, but dealing with let
      binders complicated things, forcing us to infer CallStacks. It turns
      out that the inference is actually unnecessary though, we can let the
      wanted CallStacks bubble up to the outer context by refusing to
      quantify over them. Eventually they'll be solved from a given CallStack
      or defaulted to the empty CallStack if they reach the top.
      So this patch prevents GHC from quantifying over CallStacks, getting us
      back to the original plan. There's a small ugliness to do with
      PartialTypeSignatures, if the partial theta contains a CallStack
      constraint, we *do* want to quantify over the CallStack; the user asked
      us to!
      Note that this means that
        foo :: _ => CallStack
        foo = getCallStack callStack
      will be an *empty* CallStack, since we won't infer a CallStack for the
      hole in the theta. I think this is the right move though, since we want
      CallStacks to be opt-in. One can always write
        foo :: (HasCallStack, _) => CallStack
        foo = getCallStack callStack
      to get the CallStack and still have GHC infer the rest of the theta.
      Test Plan: ./validate
      Reviewers: goldfire, simonpj, austin, hvr, bgamari
      Reviewed By: simonpj, bgamari
      Subscribers: bitemyapp, thomie
      Projects: #ghc
      Differential Revision: https://phabricator.haskell.org/D1912
      GHC Trac Issues: #11573
      (cherry picked from commit 7407a66d)
  5. 30 Mar, 2016 1 commit
    • Ben Gamari's avatar
      Defer inlining of Ord methods · 007bb347
      Ben Gamari authored
      This performs the same refactoring performed in D1980 for Eq on Ord,
      rewriting the class operations in terms of monomorphic helpers than can
      be reliably matched in rewrite rules.
      (cherry picked from commit c0e3e63e)
  6. 29 Mar, 2016 4 commits
  7. 25 Mar, 2016 1 commit
  8. 24 Mar, 2016 1 commit
    • Ben Gamari's avatar
      Defer inlining of Eq for primitive types · ed3398d1
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      This is one solution to #11688, wherein (==) was inlined to soon
      defeating a rewrite rule provided by bytestring. Since the RHSs of Eq's
      methods are simple, there is little to be gained and much to be lost by
      inlining them early.
      For instance, the bytestring library provides,
      break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
      breakByte :: Word8 -> ByteString -> (ByteString, ByteString)
      and a rule
      forall x. break ((==) x) = breakByte x
      since `breakByte` implments an optimized version of `break (== x)` for
      known `x :: Word8`. If we allow `(==)` to be inlined too early, we will
      prevent this rule from firing. This was the cause of #11688.
      This patch just defers the `Eq` methods, although it's likely worthwhile
      giving `Ord` this same treatment. This regresses compiler allocations
      for T9661 by about 8% due to the additional inlining that we now require
      the simplifier to perform.
      Updates the `bytestring` submodule to include updated rewrite rules
      which match on `eqWord8` instead of `(==)`.
      Test Plan:
       * Validate, examine performance impact
      Reviewers: simonpj, hvr, austin
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D1980
      GHC Trac Issues: #11688
      (cherry picked from commit 0bd0c31e)
  9. 23 Mar, 2016 2 commits
  10. 13 Mar, 2016 1 commit
    • eir@cis.upenn.edu's avatar
      Address #11471 by putting RuntimeRep in kinds. · 223ef8db
      eir@cis.upenn.edu authored and Ben Gamari's avatar Ben Gamari committed
      See Note [TYPE] in TysPrim. There are still some outstanding
      pieces in #11471 though, so this doesn't actually nail the bug.
      This commit also contains a few performance improvements:
      * Short-cut equality checking of nullary type syns
      * Compare types before kinds in eqType
      * INLINE coreViewOneStarKind
      * Store tycon binders separately from kinds.
      This resulted in a ~10% performance improvement in compiling
      the Cabal package. No change in functionality other than
      performance. (This affects the interface file format, though.)
      This commit updates the haddock submodule.
      (cherry picked from commit d8c64e86)
  11. 12 Mar, 2016 1 commit
  12. 11 Mar, 2016 2 commits
    • Ben Gamari's avatar
      Use catchException in a few more places · caef2856
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      These are cases in the standard library that may benefit from the
      strictness signature of catchException and where we know that the action
      won't bottom.
      Test Plan: Validate, carefully consider changed callsites
      Reviewers: austin, hvr
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D1972
      (cherry picked from commit a1c4230e)
    • Ben Gamari's avatar
      Make `catch` lazy in the action · 2e0ef457
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      catch (error "uh oh") (\(_ :: SomeException) -> print "it failed")
      would unexpectedly fail with "uh oh" instead of the handler being run
      due to the strictness of `catch` in its first argument. See #11555 for
      Test Plan: Validate
      Reviewers: austin, hvr, simonpj
      Reviewed By: simonpj
      Subscribers: simonpj, thomie
      Differential Revision: https://phabricator.haskell.org/D1973
      GHC Trac Issues: #11555
      (cherry picked from commit 30ee9102)
  13. 29 Feb, 2016 2 commits
  14. 27 Feb, 2016 8 commits
  15. 21 Feb, 2016 1 commit
  16. 18 Feb, 2016 2 commits
  17. 11 Feb, 2016 1 commit
  18. 07 Feb, 2016 1 commit
  19. 06 Feb, 2016 2 commits
  20. 04 Feb, 2016 1 commit
    • Georgios Karachalias's avatar
      Overhaul the Overhauled Pattern Match Checker · 6e23b680
      Georgios Karachalias authored and Ben Gamari's avatar Ben Gamari committed
      Overhaul the Overhauled Pattern Match Checker
      * Changed the representation of Value Set Abstractions. Instead of
      using a prefix tree, we now use a list of Value Vector Abstractions.
      The set of constraints Delta for every Value Vector Abstraction is the
      oracle state so that we solve everything only once.
      * Instead of doing everything lazily, we prune at once (and in general
      everything is much stricter). Hence, an example written with pattern
      guards is checked in almost the same time as the equivalent with
      pattern matching.
      * Do not store the covered and the divergent sets at all. Since what we
      only need is a yes/no (does this clause cover anything? Does it force
      any thunk?) We just keep a boolean for each.
      * Removed flags `-Wtoo-many-guards` and `-ffull-guard-reasoning`.
      Replaced with `fmax-pmcheck-iterations=n`. Still debatable what should
      the default `n` be.
      * When a guard is for sure not going to contribute anything, we treat
      it as such: The oracle is not called and cases `CGuard`, `UGuard` and
      `DGuard` from the paper are not happening at all (the generation of a
      fresh variable, the unfolding of the pattern list etc.). his combined
      with the above seems to be enough to drop the memory increase for test
      T783 down to 18.7%.
      * Do not export function `dsPmWarn` (it is now called directly from
      within `checkSingle` and `checkMatches`).
      * Make `PmExprVar` hold a `Name` instead of an `Id`. The term oracle
      does not handle type information so using `Id` was a waste of
      * Added testcases T11195, T11303b (data families) and T11374
      The patch addresses at least the following:
      Trac #11195, #11276, #11303, #11374, #11162
      Test Plan: validate
      Reviewers: goldfire, bgamari, hvr, austin
      Subscribers: simonpj, thomie
      Differential Revision: https://phabricator.haskell.org/D1795
      (cherry picked from commit 28f951ed)
  21. 02 Feb, 2016 1 commit
    • Ryan Scott's avatar
      Make TypeError a newtype, add changelog entry · fc5ed862
      Ryan Scott authored and Ben Gamari's avatar Ben Gamari committed
      Phab:D866 added the `TypeError` datatype to `Control.Exception` to represent
      the error that is thrown when `-fdefer-type-errors` is on, but a changelog
      entry for it was never added. In addition, it should probably be a
      Reviewers: austin, hvr, KaneTW, bgamari
      Reviewed By: KaneTW, bgamari
      Subscribers: thomie, KaneTW
      Differential Revision: https://phabricator.haskell.org/D1873
      GHC Trac Issues: #10284
      (cherry picked from commit a7ad0b91)