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. 06 Apr, 2016 3 commits
  5. 04 Apr, 2016 2 commits
    • 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)
    • Ben Gamari's avatar
      Bump binary submodule · 0ecd69bd
      Ben Gamari authored
      (cherry picked from commit 9b6820cd)
  6. 30 Mar, 2016 3 commits
  7. 29 Mar, 2016 4 commits
  8. 28 Mar, 2016 1 commit
  9. 25 Mar, 2016 1 commit
  10. 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)
  11. 23 Mar, 2016 2 commits
  12. 15 Mar, 2016 1 commit
  13. 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)
  14. 12 Mar, 2016 1 commit
  15. 11 Mar, 2016 3 commits
  16. 08 Mar, 2016 3 commits
  17. 01 Mar, 2016 1 commit
  18. 29 Feb, 2016 3 commits
    • Nicolas Trangez's avatar
      Build system: Correctly pass `TARGETPLATFORM` as host · 8c04585b
      Nicolas Trangez authored and Ben Gamari's avatar Ben Gamari committed
      When building the bundled GMP sources, the `HOSTPLATFORM` value was
      passed to the `--host` flag of the `./configure` call. This is
      incorrect: when building a cross-compiler, e.g. a compiler targeting
      ARM but running on X86, the host on which GMP will run is ARM, i.e.
      the target platform of the compiler, and the host platform (i.e. the
      platform on which the compiler will run) is X86.
      See e.g. [1] for more information about the meaning of and relation
      between build, host and target.
      [1] https://www.gnu.org/software/autoconf/manual/
      Test Plan: Building ARM cross-compiler with `integer-gmp`
      Reviewers: thomie, gracjan, austin, erikd, Phyx, hvr, bgamari
      Reviewed By: erikd, bgamari
      Subscribers: erikd, gracjan
      Differential Revision: https://phabricator.haskell.org/D1960
      (cherry picked from commit 16e97c16)
    • Ben Gamari's avatar
      base: Mark Data.Type.Equality as Trustworthy · 90d2cd72
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      Test Plan: Validate
      Reviewers: austin, ekmett, hvr
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D1957
      GHC Trac Issues: #11625
      (cherry picked from commit ad4428dd)
    • Ryan Scott's avatar
      Missing Proxy instances, make U1 instance more Proxy-like · 18e5edc0
      Ryan Scott authored and Ben Gamari's avatar Ben Gamari committed
      This accomplishes three things:
      * Adds missing `Alternative`, `MonadPlus`, and `MonadZip` instances for
      * Adds a missing `MonadPlus` instance for `U1`
      * Changes several existing `U1` instances to use lazy pattern-matching,
        exactly how `Proxy` does it (in case we ever replace `U1` with
        `Proxy`). This is technically a breaking change (albeit an extremely
        minor one).
      Test Plan: ./validate
      Reviewers: austin, ekmett, hvr, bgamari
      Reviewed By: bgamari
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D1962
      GHC Trac Issues: #11650
      (cherry picked from commit 171d95df)
  19. 28 Feb, 2016 1 commit
  20. 27 Feb, 2016 2 commits
    • Ben Gamari's avatar
      GHC.Generics: Ensure some, many for U1 don't bottom · b89747e3
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      Reviewers: austin, hvr, ekmett, RyanGlScott
      Reviewed By: RyanGlScott
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D1952
      GHC Trac Issues: #11650
      (cherry picked from commit 890e2bb7)
    • Ryan Scott's avatar
      Add more type class instances for GHC.Generics · 1fcddf82
      Ryan Scott authored and Ben Gamari's avatar Ben Gamari committed
      GHC.Generics provides several representation data types that have
      obvious instances of various type classes in base, along with various
      other types of meta-data (such as associativity and fixity).
      Specifically, instances have been added for the following type classes
      (where possible):
          - Applicative
          - Data
          - Functor
          - Monad
          - MonadFix
          - MonadPlus
          - MonadZip
          - Foldable
          - Traversable
          - Enum
          - Bounded
          - Ix
          - Generic1
      Thanks to ocharles for starting this!
      Test Plan: Validate
      Reviewers: ekmett, austin, hvr, bgamari
      Reviewed By: bgamari
      Subscribers: RyanGlScott, thomie
      Differential Revision: https://phabricator.haskell.org/D1937
      GHC Trac Issues: #9043
      (cherry picked from commit 673efccb)