1. 12 Sep, 2017 1 commit
  2. 07 Sep, 2017 1 commit
  3. 31 Aug, 2017 2 commits
    • Herbert Valerio Riedel's avatar
      Add missing Semigroup instances to compiler · c0feee90
      Herbert Valerio Riedel authored
      This is a pre-requisite for implementing the Semigroup/Monoid proposal.
      The instances have been introduced in a way to minimise warnings.
      c0feee90
    • Simon Peyton Jones's avatar
      Add debugPprType · 805b29bb
      Simon Peyton Jones authored
      We pretty-print a type by converting it to an IfaceType and
      pretty-printing that.  But
       (a) that's a bit indirect, and
       (b) delibrately loses information about (e.g.) the kind
            on the /occurrences/ of a type variable
      
      So this patch implements debugPprType, which pretty prints
      the type directly, with no fancy formatting.  It's just used
      for debugging.
      
      I took the opportunity to refactor the debug-pretty-printing
      machinery a little.  In particular, define these functions
      and use them:
      
        ifPprDeubug :: SDoc -> SDOc -> SDoc
          -- Says what to do with and without -dppr-debug
        whenPprDebug :: SDoc -> SDoc
          -- Says what to do with  -dppr-debug; without is empty
        getPprDebug :: (Bool -> SDoc) -> SDoc
      
      getPprDebug used to be called sdocPprDebugWith
      whenPprDebug used to be called ifPprDebug
      
      So a lot of files get touched in a very mechanical way
      805b29bb
  4. 29 Aug, 2017 4 commits
    • Ben Gamari's avatar
      Add a Note describing #14128 · 6f1ccaa5
      Ben Gamari authored
      I prematurely committed the D3892 before adding a Note. Fix this.
      6f1ccaa5
    • Ryan Scott's avatar
      Refactor type family instance abstract syntax declarations · 895a7650
      Ryan Scott authored
      This implements @simonpj's suggested refactoring of the abstract syntax
      for type/data family instances (from
      https://ghc.haskell.org/trac/ghc/ticket/14131#comment:9). This combines
      the previously separate `TyFamEqn` and `DataFamInstDecl` types into a
      single `FamEqn` datatype. This also factors the `HsImplicitBndrs` out of
      `HsTyPats` in favor of putting them just outside of `FamEqn` (as opposed
      to before, where all of the implicit binders were embedded inside of
      `TyFamEqn`/`DataFamInstDecl`). Finally, along the way I noticed that
      `dfid_fvs` and `tfid_fvs` were completely unused, so I removed them.
      
      Aside from some changes in parser test output, there is no change in
      behavior.
      
      Requires a Haddock submodule commit from my fork (at
      https://github.com/RyanGlScott/haddock/commit/815d2deb9c0222c916becccf84
      64b740c26255fd)
      
      Test Plan: ./validate
      
      Reviewers: simonpj, austin, goldfire, bgamari, alanz
      
      Reviewed By: bgamari
      
      Subscribers: mpickering, goldfire, rwbarton, thomie, simonpj
      
      GHC Trac Issues: #14131
      
      Differential Revision: https://phabricator.haskell.org/D3881
      895a7650
    • Ben Gamari's avatar
      desugar: Ensure that a module's dep_orphs doesn't contain itself · db3a8e16
      Ben Gamari authored
      Consider that we have two modules, A and B, both with hs-boot files,
      
        * A.hs contains a SOURCE import of B
        * B.hs-boot contains a SOURCE import of A
        * A.hs-boot declares an orphan instance
        * A.hs defines the orphan instance
      
      In this case, B's dep_orphs will contain A due to its SOURCE import of
      A.  Consequently, A will contain itself in its imp_orphs due to its
      import of B.  This fact would end up being recorded in A's interface
      file. This would then break the invariant asserted by calculateAvails
      that a module does not itself in its dep_orphs. This was the cause
      of #14128.
      
      The solution is to remove self-references from imp_orphs when
      constructing dep_orphs; we already did a similar thing for dep_mods. I
      believe we should do the same for dep_finsts, although I'm treating this
      as a separate bug.
      
      Reviewers: austin
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3892
      db3a8e16
    • Simon Peyton Jones's avatar
      Small refactor of getRuntimeRep · a6c448b4
      Simon Peyton Jones authored
      Instead of using a string argument, use HasDebugCallStack.
      (Oddly, some functions were using both!)
      
      Plus, use getRuntimeRep rather than getRuntimeRep_maybe when
      if the caller panics on Nothing. Less code, and a better debug
      stack.
      a6c448b4
  5. 18 Aug, 2017 1 commit
  6. 15 Aug, 2017 1 commit
    • Ryan Scott's avatar
      Don't drop GHCi-defined functions with -fobject-code enabled · ddb870bf
      Ryan Scott authored
      The desugarer was using `targetRetainsAllBindings` as a litmus test for
      determining if a function was defined in interactive mode (and thus
      should be exported). However, there is a corner case where one can be in
      interactive mode and have `targetRetainsAllBindings` return `False`: if
      `-fobject-code` is enabled (since the target will no longer be
      `HscInteractive`). In such a scenario, we should fall back on a
      different test for determining if we are in a GHCi session. I chose to
      use `isInteractiveModule`, which appears to do the trick.
      
      Test Plan: make test TEST=T12091
      
      Reviewers: austin, bgamari
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #12091
      
      Differential Revision: https://phabricator.haskell.org/D3849
      ddb870bf
  7. 12 Aug, 2017 1 commit
    • Ryan Scott's avatar
      Change isClosedAlgType to be TYPE-aware, and rename it to pmIsClosedType · 4f1f9868
      Ryan Scott authored
      Summary:
      In a267580e, I somewhat awkwardly
      inserted a special case for `TYPE` in the `EmptyCase` coverage checker.
      Instead of placing it there, @mpickering noted that `isClosedAlgType` would
      be a better fit for it. I do just that in this patch.
      
      I also renamed `isClosedAlgType` to `pmIsClosedType`, reflecting the fact that
      `TYPE` technically isn't an algebraic type (it's a primitive one), and that its
      behavior is pattern-match coverage checking-oriented. I also moved it to
      `Check`, which is a better home for this function than `Type`. Luckily,
      the only call sites for `isClosedAlgType` were in the pattern-match coverage
      checker anyways, so this change is simple enough.
      
      Test Plan: ./validate
      
      Reviewers: mpickering, austin, goldfire, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, thomie, mpickering
      
      GHC Trac Issues: #14086
      
      Differential Revision: https://phabricator.haskell.org/D3830
      4f1f9868
  8. 05 Aug, 2017 1 commit
    • Ryan Scott's avatar
      Don't warn when empty casing on Type · a267580e
      Ryan Scott authored
      Summary:
      `Type` (a.k.a. `TYPE LiftedRep`) can be used at the type level thanks
      to `TypeInType`. However, expressions like
      
      ```lang=haskell
      f :: Type -> Int
      f x = case x of {}
      ```
      
      were falsely claiming that the empty case on the value of type `Type` was
      non-exhaustive. The reason is a bit silly: `TYPE` is technically not an empty
      datatype in GHC's eyes, since it's a builtin, primitive type. To convince the
      pattern coverage checker otherwise, this adds a special case for `TYPE`.
      
      Test Plan: make test TEST=T14086
      
      Reviewers: gkaracha, austin, bgamari, goldfire
      
      Reviewed By: goldfire
      
      Subscribers: goldfire, rwbarton, thomie
      
      GHC Trac Issues: #14086
      
      Differential Revision: https://phabricator.haskell.org/D3819
      a267580e
  9. 01 Aug, 2017 2 commits
  10. 31 Jul, 2017 5 commits
    • Simon Peyton Jones's avatar
      Use field names for all uses of datacon Match · 4fdc5234
      Simon Peyton Jones authored
      This is refactoring only... elimiante all positional uses
      of the data constructor Match in favour of field names.
      
      No change in behaviour.
      4fdc5234
    • Simon Peyton Jones's avatar
      Remove redundant goop · 7f2dee8e
      Simon Peyton Jones authored
      See comment:22 in Trac #13594
      7f2dee8e
    • Simon Peyton Jones's avatar
      Reject top-level banged bindings · af89d687
      Simon Peyton Jones authored
      Bizarrely, we were not rejecting
        !x = e
      
      Fix:
      
      * In the test in DsBinds.dsTopLHsBinds, use isBangedHsBind, not
        isBangedPatBind.  (Indeed the latter dies altogther.)
      
      * Implement isBangedHsBind in HsUtils;
        be sure to handle AbsBinds
      
      All this was shown up by Trac #13594
      af89d687
    • Simon Peyton Jones's avatar
      Improve the desugaring of -XStrict · 46368868
      Simon Peyton Jones authored
      Trac #14035 showed that -XStrict was generating some TERRIBLE
      desugarings, espcially for bindings with INLINE pragmas. Reason: with
      -XStrict, all AbsBinds (even for non-recursive functions) went via the
      general-case deguaring for AbsBinds, namely "generate a tuple and
      select from it", even though in this case there was only one variable
      in the tuple.  And that in turn interacts terribly badly with INLINE
      pragmas.
      
      This patch cleans things up:
      
      * I killed off AbsBindsSig completely, in favour of a boolean flag
        abs_sig in AbsBinds.  See Note [The abs_sig field of AbsBinds]
      
        This allowed me to delete lots of code; and instance-method
        declarations can enjoy the benefits too.  (They could have
        before, but no one had changed them to use AbsBindsSig.)
      
      * I refactored all the AbsBinds handling in DsBinds into a new
        function DsBinds.dsAbsBinds.  This allowed me to handle the
        strict case uniformly
      46368868
    • Simon Peyton Jones's avatar
      Refactoring around FunRhs · 2535a671
      Simon Peyton Jones authored
      * Clarify the comments around the mc_strictness field of FunRhs
      * Use record field names consistently for FunRhs
      2535a671
  11. 28 Jul, 2017 2 commits
    • Ryan Scott's avatar
      Merge types and kinds in DsMeta · b3b564fb
      Ryan Scott authored
      Summary:
      Types and kinds are now the same in GHC... well, except in the code
      that involves Template Haskell, where types and kinds are given separate
      treatment. This aims to unify that treatment in the `DsMeta` module.
      
      The gist of this patch is replacing all uses of `repLKind` with `repLTy`.
      This is isn't quite as simple as one might imagine, since `repLTy` returns a
      `Core (Q Type)` (a monadic expression), whereas `repLKind` returns a
      `Core Kind` (a pure expression). This causes many awkward impedance mismatches.
      
      One option would be to change every combinator in `Language.Haskell.TH.Lib` to
      take `KindQ` as an argument instead of `Kind`. But this would be a breaking
      change of colossal proportions.
      
      Instead, this patch takes a somewhat different approach. This migrates the
      existing `Language.Haskell.TH.Lib` module to
      `Language.Haskell.TH.Lib.Internal`, and changes all `Kind`-related combinators
      in `Language.Haskell.TH.Lib.Internal` to live in `Q`. The new
      `Language.Haskell.TH.Lib` module then re-exports most of
      `Language.Haskell.TH.Lib.Internal` with the exception of the `Kind`-related
      combinators, for which it redefines them to be their current definitions (which
      don't live in `Q`). This allows us to retain backwards compatibility with
      previous `template-haskell` releases, but more importantly, it allows GHC to
      make as many changes to the `Internal` code as it wants for its purposes
      without fear of disrupting the public API.
      
      This solves half of #11785 (the other half being `TcSplice`).
      
      Test Plan: ./validate
      
      Reviewers: goldfire, austin, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #11785
      
      Differential Revision: https://phabricator.haskell.org/D3751
      b3b564fb
    • Simon Peyton Jones's avatar
      Fix instantiation of pattern synonyms · 6b77914c
      Simon Peyton Jones authored
      In Check.hs (pattern match ovelap checking) we to figure out the
      instantiation of a pattern synonym from the type of the pattern. We
      were doing this utterly wrongly.  Trac #13768 demonstrated this
      bogosity.
      
      The fix is easy; and is described in PatSyn.hs
        Note [Pattern synonym result type]
      6b77914c
  12. 18 Jul, 2017 1 commit
  13. 11 Jul, 2017 1 commit
  14. 28 Jun, 2017 1 commit
  15. 27 Jun, 2017 1 commit
  16. 12 Jun, 2017 2 commits
    • Ryan Scott's avatar
      Support signatures at the kind level in Template Haskell · 9a3ca8de
      Ryan Scott authored
      `repNonArrowKind` was missing a case for `HsKindSig`, which this
      commit adds. Fixes #13781.
      
      Test Plan: make test TEST=T13781
      
      Reviewers: goldfire, austin, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #13781
      
      Differential Revision: https://phabricator.haskell.org/D3627
      9a3ca8de
    • niteria's avatar
      Fix #13807 - foreign import nondeterminism · dcdc3916
      niteria authored
      The problem was that the generated label included
      a freshly assigned Unique value.
      
      Test Plan:
      Added a new test and looked at the generated stub:
      
      ```
       #include "HsFFI.h"
       #ifdef __cplusplus
       extern "C" {
       #endif
       extern HsInt zdmainzdAzdAzuzzlzzgzzg(StgStablePtr the_stableptr);
       extern HsInt zdmainzdAzdAzumkStringWriter(StgStablePtr the_stableptr);
       #ifdef __cplusplus
       }
       #endif
      ```
      
      ./validate
      
      Reviewers: simonmar, austin, bgamari
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #13807
      
      Differential Revision: https://phabricator.haskell.org/D3633
      dcdc3916
  17. 05 Jun, 2017 1 commit
    • Alan Zimmerman's avatar
      Udate hsSyn AST to use Trees that Grow · 8e6ec0fa
      Alan Zimmerman authored
      Summary:
      See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow
      
      This commit prepares the ground for a full extensible AST, by replacing the type
      parameter for the hsSyn data types with a set of indices into type families,
      
          data GhcPs -- ^ Index for GHC parser output
          data GhcRn -- ^ Index for GHC renamer output
          data GhcTc -- ^ Index for GHC typechecker output
      
      These are now used instead of `RdrName`, `Name` and `Id`/`TcId`/`Var`
      
      Where the original name type is required in a polymorphic context, this is
      accessible via the IdP type family, defined as
      
          type family IdP p
          type instance IdP GhcPs = RdrName
          type instance IdP GhcRn = Name
          type instance IdP GhcTc = Id
      
      These types are declared in the new 'hsSyn/HsExtension.hs' module.
      
      To gain a better understanding of the extension mechanism, it has been applied
      to `HsLit` only, also replacing the `SourceText` fields in them with extension
      types.
      
      To preserve extension generality, a type class is introduced to capture the
      `SourceText` interface, which must be honoured by all of the extension points
      which originally had a `SourceText`.  The class is defined as
      
          class HasSourceText a where
            -- Provide setters to mimic existing constructors
            noSourceText  :: a
            sourceText    :: String -> a
      
            setSourceText :: SourceText -> a
            getSourceText :: a -> SourceText
      
      And the constraint is captured in `SourceTextX`, which is a constraint type
      listing all the extension points that make use of the class.
      
      Updating Haddock submodule to match.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, shayan-najd, goldfire, austin, bgamari
      
      Subscribers: rwbarton, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D3609
      8e6ec0fa
  18. 02 Jun, 2017 1 commit
    • Ryan Scott's avatar
      Use lengthIs and friends in more places · a786b136
      Ryan Scott authored
      While investigating #12545, I discovered several places in the code
      that performed length-checks like so:
      
      ```
      length ts == 4
      ```
      
      This is not ideal, since the length of `ts` could be much longer than 4,
      and we'd be doing way more work than necessary! There are already a slew
      of helper functions in `Util` such as `lengthIs` that are designed to do
      this efficiently, so I found every place where they ought to be used and
      did just that. I also defined a couple more utility functions for list
      length that were common patterns (e.g., `ltLength`).
      
      Test Plan: ./validate
      
      Reviewers: austin, hvr, goldfire, bgamari, simonmar
      
      Reviewed By: bgamari, simonmar
      
      Subscribers: goldfire, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3622
      a786b136
  19. 15 May, 2017 3 commits
  20. 12 May, 2017 2 commits
    • Ben Gamari's avatar
      Revert "Treat banged bindings as FunBinds" · 3032ae81
      Ben Gamari authored
      This partially reverts commit 37299536 as it
      doesn't actually fix #13594. Namely it does not revert the mkPrefixFunRhs
      refactoring since this is rather independent from the functional changes.
      
      Going to try again with a whole working patch
      3032ae81
    • David Feuer's avatar
      Automatically add SCCs to INLINABLE bindings · ab91daf2
      David Feuer authored
      Instead of excluding `isAnyInlinePragma`, just exclude
      `isInlinePragma`. This makes GHC behave as documented;
      the user's guide only indicates that GHC does not automatically
      add SCCs to `INLINE` bindings.
      
      Fixes #12962.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: DemiMarie, osa1, Mikolaj, simonpj, rwbarton, thomie
      
      GHC Trac Issues: #12962
      
      Differential Revision: https://phabricator.haskell.org/D3550
      ab91daf2
  21. 11 May, 2017 2 commits
  22. 09 May, 2017 1 commit
    • Ben Gamari's avatar
      Treat banged bindings as FunBinds · 37299536
      Ben Gamari authored
      This reworks the HsSyn representation to make banged variable patterns
      (e.g. !x = e) be represented as FunBinds instead of PatBinds, adding a flag to
      FunRhs to record the bang.
      
      Fixes #13594.
      
      Reviewers: austin, goldfire, alanz, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D3525
      37299536
  23. 08 May, 2017 1 commit
  24. 04 May, 2017 1 commit
    • Simon Peyton Jones's avatar
      Deal with exceptions in dsWhenNoErrs · e7701976
      Simon Peyton Jones authored
      Gracious me.  Ever since this patch
      
        commit 37445780
        Author: Jan Stolarek <jan.stolarek@p.lodz.pl>
        Date:   Fri Jul 11 13:54:45 2014 +0200
      
            Injective type families
      
      TcRnMonad.askNoErrs has been wrong. It looked like this
      
         askNoErrs :: TcRn a -> TcRn (a, Bool)
         askNoErrs m
          = do { errs_var <- newTcRef emptyMessages
               ; res  <- setErrsVar errs_var m
               ; (warns, errs) <- readTcRef errs_var
               ; addMessages (warns, errs)
               ; return (res, isEmptyBag errs) }
      
      The trouble comes if 'm' throws an exception in the TcRn monad.
      Then 'errs_var is never read, so any errors are simply lost.
      
      This mistake was then propgated into DsMonad.dsWhenNoErrs, where
      it gave rise to Trac #13642.
      
      Thank to Ryan for narrowing it down so sharply.
      
      I did some refactoring, as usual.
      e7701976
  25. 03 May, 2017 1 commit