1. 11 May, 2015 8 commits
    • Edward Z. Yang's avatar
      Support stage 1 Template Haskell (non-quasi) quotes, fixes #10382. · f16ddcee
      Edward Z. Yang authored
      Summary:
      This commit adds stage 1 support for Template Haskell
      quoting, e.g. [| ... expr ... |], which is useful
      for authors of quasiquoter libraries that do not actually
      need splices.  The TemplateHaskell extension now does not
      unconditionally fail; it only fails if the renamer encounters
      a splice that it can't run.
      
      In order to make sure the referenced data structures
      are consistent, template-haskell is now a boot library.
      There are some minor BC changes to template-haskell to make it boot
      on GHC 7.8.
      
      Note for reviewer: big diff changes are simply code
      being moved out of an ifdef; there was no other substantive
      change to that code.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, goldfire
      
      Subscribers: bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D876
      
      GHC Trac Issues: #10382
      f16ddcee
    • Alan Zimmerman's avatar
      ApiAnnotations : PatBind gives wrong SrcSpan for the pattern. · ecc3d6be
      Alan Zimmerman authored
      Summary:
      The production for decl_no_th starts
      
          decl_no_th :: { Located (OrdList (LHsDecl RdrName)) }
                  : sigdecl               { $1 }
      
                  | '!' aexp rhs  {% do { let { e = sLL $1 $> (SectionR (sL1 $1 (HsVar bang_RDR)) $2) };
                                          pat <- checkPattern empty e;
          ...
      
      The e value should be just the pattern, excluding the rhs, but the span
      created includes the rhs.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: bgamari, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D873
      
      GHC Trac Issues: #10358
      ecc3d6be
    • Alan Zimmerman's avatar
      ApiAnnotations : pquals production adds AnnVbar in the wrong place · fe38195e
      Alan Zimmerman authored
      Summary:
      The Parser.y production for pquals is
      
          pquals :: { Located [[LStmt RdrName (LHsExpr RdrName)]] }
              : squals '|' pquals
                               {% addAnnotation (gl $ last $ unLoc $1) AnnVbar (gl $2) >>
                                  return (sLL $1 $> (reverse (unLoc $1) : unLoc $3)) }
              | squals         { L (getLoc $1) [reverse (unLoc $1)] }
      
      The squals are returned in reverse order, so the AnnVbar should be
      attached to the head of the list, not the last.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D869
      
      GHC Trac Issues: #10357
      fe38195e
    • Alan Zimmerman's avatar
      ApiAnnotations : BooleanFormula construction discards original · 24707d72
      Alan Zimmerman authored
      Summary:
      The MINIMAL pragma is captured in the parser using a BooleanFormula.
      
      The constructors (mkBool,mkAnd,mkOr) are smart and try to minimise the
      boolean formula as it is constructed.
      
      This discards the original information, making round tripping
      impossible.
      
      Note: there is another version which provides a more API Annotations
      friendly version of the MINIMAL pragma, but this requires changes to
      haddock, which will cause problems for 7.10.2.
      
      See https://github.com/alanz/ghc/tree/wip/10287
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: bgamari, Fuuzetsu, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D837
      
      GHC Trac Issues: #10287
      24707d72
    • Austin Seipp's avatar
      compiler: make sure we reject -O + HscInterpreted · 9736c042
      Austin Seipp authored
      When using GHCi, we explicitly reject optimization, because the
      compilers optimization passes can introduce unboxed tuples, which the
      interpreter is not able to handle. But this goes the other way too: using
      GHCi on optimized code may cause the optimizer to float out breakpoints
      that the interpreter introduces. This manifests itself in weird ways,
      particularly if you as an API client use custom DynFlags to introduce
      optimization in combination with HscInterpreted.
      
      It turns out we weren't checking for consistent DynFlag settings when
      doing `setSessionDynFlags`, as #10052 showed. While the main driver
      handled it in `DynFlags` via `parseDynamicFlags`, we didn't check this
      elsewhere.
      
      This does a little refactoring to split out some of the common code, and
      immunizes the various `DynFlags` utilities in the `GHC` module from this
      particular bug. We should probably be checking other general invariants
      too.
      
      This fixes #10052, and adds some notes about the behavior in `GHC` and
      `FloatOut`
      
      As a bonus, expose `warningMsg` from `ErrUtils` as a helper since it
      didn't exist (somehow).
      Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
      
      Reviewed By: edsko
      
      Differential Revision: https://phabricator.haskell.org/D727
      
      GHC Trac Issues: #10052
      9736c042
    • Simon Marlow's avatar
      More accurate allocation stats for :set +s · cf7573b8
      Simon Marlow authored
      The point of this commit is to make the memory allocation statistic
      from :set +s in GHCi a lot more accurate.  Currently it uses the total
      allocation figure calculated by the RTS, which is only updated during
      GC, so can be wrong by an arbitrary amount.  The fix is to the the
      per-thread allocation counter that was introduced for allocation
      limits.
      
      This required changes to the GHC API, because we now have to return
      the allocation value from each evaluation.  Rather than just change
      the API, I introduced a new API and deprecated the old one.  The new
      one is simpler and more extensible, so hopefully we won't need to make
      this transition in the future.  See GHC.hs for details.
      cf7573b8
    • Alan Zimmerman's avatar
      ApiAnnotations : mkGadtDecl discards annotations for HsFunTy · e4032b19
      Alan Zimmerman authored
      Summary:
      When mkGadtDecl is presented wih a HsFunTy it discards the SrcSpan, thus
      disconnecting any annotations on the HsFunTy.
      
      ```
      mkGadtDecl names (L ls (HsForAllTy imp Nothing qvars cxt tau))
        = return $ mk_gadt_con names
        where
          (details, res_ty)           -- See Note [Sorting out the result type]
            = case tau of
                L _ (HsFunTy (L l (HsRecTy flds)) res_ty)
                                                  -> (RecCon (L l flds), res_ty)
                _other                                    -> (PrefixCon [], tau)
      ...
      ```
      
      This can be triggered by the following
      
      ```
      {-# LANGUAGE GADTs #-}
      module GADTRecords2 (H1(..)) where
      
      -- | h1
      data H1 a b where
        C3 :: (Num a) => { field :: a -- ^ hello docs
                         } -> H1 Int Int
      ```
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: bgamari, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D848
      
      GHC Trac Issues: #10309
      e4032b19
    • Alan Zimmerman's avatar
      Api Annotations: RdrHsSyn.mkAtDefault causes annotations to be disconnected. · 811b72ad
      Alan Zimmerman authored
      Summary:
      The code for mkAtDefault is as follows.
      
          mkATDefault (L loc (TyFamInstDecl { tfid_eqn = L _ e }))
                | TyFamEqn { tfe_tycon = tc, tfe_pats = pats, tfe_rhs = rhs } <- e
                = do { tvs <- checkTyVars (ptext (sLit "default")) equalsDots tc (hswb_cts pats)
                     ; return (L loc (TyFamEqn { tfe_tycon = tc
                                               , tfe_pats = tvs
                                               , tfe_rhs = rhs })) }
      
      An associated type in a class of the form
      
          type FoldableConstraint t x = ()
      
      has an AnnEqual attached to the location in tfid_eqn. Since the location
      is discarded, this annotation is then disconnected from the AST.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: bgamari, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D842
      
      GHC Trac Issues: #10307
      811b72ad
  2. 09 May, 2015 4 commits
  3. 08 May, 2015 2 commits
    • Alan Zimmerman's avatar
      ApiAnnotations: misplaced AnnComma for squals production · 71361267
      Alan Zimmerman authored
      Summary:
      The parser production for squals has
      
          : squals ',' transformqual
                   {% addAnnotation (gl $ last $ unLoc $1) AnnComma (gl $2) >>
                      ams (sLL $1 $> ()) (fst $ unLoc $3) >>
                      return (sLL $1 $> [sLL $1 $> ((snd $ unLoc $3) (reverse (unLoc $1)))]) }
      
      This attaches the comma to the wrong part of the squals, as it is
      generated in reverse order.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: bgamari, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D846
      
      GHC Trac Issues: #10312
      71361267
    • Alan Zimmerman's avatar
      ApiAnnotations : AnnComma missing in TupleSection · 225df19a
      Alan Zimmerman authored
      Summary:
      For the following code
      
        {-# LANGUAGE TupleSections #-}
      
        foo = do
          liftIO $ atomicModifyIORef ciTokens ((,()) . f)
      
      the annotation is missing for the comma.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D834
      
      GHC Trac Issues: #10280
      225df19a
  4. 07 May, 2015 2 commits
    • Alan Zimmerman's avatar
      ApiAnnotations : RdrHsSyn.isFunLhs discards parentheses · 5bde9f7c
      Alan Zimmerman authored
      Summary:
      The RdrHsSyn.isFunLhs function has the following
      
        isFunLhs e = go e []
         where
           go (L loc (HsVar f)) es
                | not (isRdrDataCon f)   = return (Just (L loc f, False, es))
           go (L _ (HsApp f e)) es       = go f (e:es)
           go (L _ (HsPar e))   es@(_:_) = go e es
      
      The treatment of HsPar means that any parentheses around an infix function will be discarded.
      
      e.g.
      
        (f =*= g) sa i = f (toF sa i) =^= g (toG sa i)
      
      will lose the ( before f and the closing one after g
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D832
      
      GHC Trac Issues: #10269
      5bde9f7c
    • Simon Peyton Jones's avatar
      Regression test for Trac #10390 · c3e6b3ac
      Simon Peyton Jones authored
      c3e6b3ac
  5. 06 May, 2015 9 commits
    • Austin Seipp's avatar
      Revert "API Annotations : add Locations in hsSyn were layout occurs" · 97d320f5
      Austin Seipp authored
      This reverts commit fb54b2c1.
      
      As Alan pointed out, this will make cherry picking a lot harder until
      7.10.2, so lets back it out until after the release.
      97d320f5
    • Austin Seipp's avatar
      Revert "ApiAnnotations : Nested forall loses forall annotation" · f34c0728
      Austin Seipp authored
      This reverts commit 81030ede.
      
      Alan is abandoning this approach in favor of D836.
      f34c0728
    • Alan Zimmerman's avatar
      ApiAnnotations : Nested forall loses forall annotation · 81030ede
      Alan Zimmerman authored
      When parsing
      
          {-# LANGUAGE ScopedTypeVariables #-}
      
          extremumNewton :: forall tag. forall tag1.
                             tag -> tag1 -> Int
          extremumNewton = undefined
      
      The parser attaches an AnnForall to the second forall, which appears as
      a nested HsForAllTy.
      
      Somewhere this nesting is flattened, and the tyvarbndrs are collapsed
      into a single HsForAllTy. In this process the second AnnForAll loses its
      anchor in the AST.
      
      Reviewed By: austin
      
      Differential Revision: https://phabricator.haskell.org/D833
      
      GHC Trac Issues: #10278
      81030ede
    • Alan Zimmerman's avatar
      ApiAnnotations : quoted type variables missing leading quote · 15aafc7f
      Alan Zimmerman authored
      The HsOpTy can be constructed for a promoted type operator, in which case it has the following form
      
              | btype SIMPLEQUOTE qconop type     { sLL $1 $> $ mkHsOpTy $1 $3 $4 }
              | btype SIMPLEQUOTE varop  type     { sLL $1 $> $ mkHsOpTy $1 $3 $4 }
      
      The SIMPLEQUOTE does not get an annotation, so cannot be reproduced via the API Annotations.
      
      Also, in
      
      splice_exp :: { LHsExpr RdrName }
              : TH_ID_SPLICE          { sL1 $1 $ mkHsSpliceE
                                              (sL1 $1 $ HsVar (mkUnqual varName
                                                              (getTH_ID_SPLICE $1))) }
              | '$(' exp ')'          {% ams (sLL $1 $> $ mkHsSpliceE $2) [mo $1,mc $3] }
              | TH_ID_TY_SPLICE       { sL1 $1 $ mkHsSpliceTE
                                              (sL1 $1 $ HsVar (mkUnqual varName
                                                           (getTH_ID_TY_SPLICE $1))) }
              | '$$(' exp ')'         {% ams (sLL $1 $> $ mkHsSpliceTE $2) [mo $1,mc $3] }
      
      the TH_ID_SPLICE and TH_ID_TY_SPLICE positions are lost.
      
      Reviewed By: austin
      
      Differential Revision: https://phabricator.haskell.org/D825
      
      GHC Trac Issues: #10268
      15aafc7f
    • Matthew Pickering's avatar
      Correct parsing of lifted empty list constructor · caeae1a3
      Matthew Pickering authored
      See #10299
      
      Previously `'[]` was parsed to a `HsTyVar` rather than a
      `HsExplicitListTy`. This patch fixes the
      shift-reduce conflict which caused this problem.
      
      Reviewed By: alanz, austin
      
      Differential Revision: https://phabricator.haskell.org/D840
      caeae1a3
    • Alan Zimmerman's avatar
      API Annotations : add Locations in hsSyn were layout occurs · fb54b2c1
      Alan Zimmerman authored
      At the moment ghc-exactprint, which uses the GHC API Annotations to
      provide a framework for roundtripping Haskell source code with optional
      AST edits, has to implement a horrible workaround to manage the points
      where layout needs to be captured.
      
      These are
      
          MatchGroup
          HsDo
          HsCmdDo
          HsLet
          LetStmt
          HsCmdLet
          GRHSs
      
      To provide a more natural representation, the contents subject to layout
      rules need to be wrapped in a SrcSpan.
      
      This commit does this.
      
      Trac ticket #10250
      
      Reviewed By: austin
      
      Differential Revision: https://phabricator.haskell.org/D815
      
      GHC Trac Issues: #10250
      fb54b2c1
    • Javran Cheng's avatar
      rts: add "-no-rtsopts-suggestions" option · 477f514f
      Javran Cheng authored
      Depends on D767
      
      Setting this flag prevents RTS from giving RTS suggestions like "Use
      `+RTS -Ksize -RTS' to increase it."
      
      According to the comment @rwbarton made in #9579, sometimes "+RTS"
      suggestions don't make sense (e.g. when the program is precompiled and
      installed through package managers), we can encourage people to
      distribute binaries with either "-no-rtsopts-suggestions" or "-rtsopts".
      
      Reviewed By: erikd, austin
      
      Differential Revision: https://phabricator.haskell.org/D809
      
      GHC Trac Issues: #9579
      477f514f
    • Vikraman Choudhury's avatar
      Fix typo: identifer -> identifier · 458a97b8
      Vikraman Choudhury authored
      I noticed this typo while using template haskell.
      Signed-off-by: default avatarVikraman Choudhury <git@vikraman.org>
      
      Test Plan:
      ```
      λ> :set -XTemplateHaskell
      λ> :m +Language.Haskell.TH
      λ> data Foo = Foo
      λ> $(conE ''Foo)
      <interactive>:9:9:
          Type constructor ‘Foo’ used where a value identifier was expected
          In the expression: Foo
          In an equation for ‘f’: f = Foo
      
      ```
      
      Reviewed By: bgamari
      
      Differential Revision: https://phabricator.haskell.org/D871
      458a97b8
    • Christiaan Baaij's avatar
      Normalise type families in the type of an expression · f7daf5af
      Christiaan Baaij authored
      Before, the type of an expression, and the type of a variable
      binding that expression used to be different in GHCi. The
      reason being that types of bound variables were already normalised.
      Now, both are normalised.
      
      This implements the suggestions as given in Trac #10321
      Also adds an expected output for test T10321
      
      Reviewed By: goldfire, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D870
      
      GHC Trac Issues: #10321
      f7daf5af
  6. 04 May, 2015 3 commits
    • Edward Z. Yang's avatar
      Give a hint when a TH splice has a bad package key, partially fixes #10279 · bf4f3e65
      Edward Z. Yang authored
      Previously, if we got a package key in our splice, we'd give
      a very unhelpful error message saying we couldn't find
      a package 'base-4.7.0.1', despite there being a package with
      that source package ID.  Really, we couldn't find a package with
      that *key*, so clarify, and also tell the user what the real
      package key is.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      bf4f3e65
    • Erik de Castro Lopo's avatar
      Fix safeHaskell test for llvm backend · f7dfcef4
      Erik de Castro Lopo authored
      Test was failing (could not execute: pgmlc) for arm (which uses
      the llvm backend) due to the `-pgmlc pgmlc` in OPTIONS_GHC. It
      was also failing on amd64 in the same way when `-fllvm` was
      added to the command line. Its safe to remove because the
      compiler should already know which llvm tool to use.
      
      Test Plan: validate
      
      Reviewers: dterei, austin
      
      Subscribers: bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D874
      f7dfcef4
    • Adam Gundry's avatar
      Permit empty closed type families · 4efa4213
      Adam Gundry authored
      Fixes #9840 and #10306, and includes an alternative resolution to #8028.
      This permits empty closed type families, and documents them in the user
      guide. It updates the Haddock submodule to support the API change.
      
      Test Plan: Added `indexed-types/should_compile/T9840` and updated
      `indexed-types/should_fail/ClosedFam4` and `th/T8028`.
      
      Reviewers: austin, simonpj, goldfire
      
      Reviewed By: goldfire
      
      Subscribers: bgamari, jstolarek, thomie, goldfire
      
      Differential Revision: https://phabricator.haskell.org/D841
      
      GHC Trac Issues: #9840, #10306
      4efa4213
  7. 01 May, 2015 1 commit
    • Simon Peyton Jones's avatar
      Move IP, Symbol, Nat to ghc-prim · 2f6a0ac7
      Simon Peyton Jones authored
      This motivation is to declare class IP much earlier (in ghc-prim),
      so that implicit parameters (which depend on IP) is available
      to library code, notably the 'error' function.
      
      * Move class IP from base:GHC.IP
                      to ghc-prim:GHC.Classes
      * Delete module GHC.IP from base
      
      * Move types Symbol and Nat
            from base:GHC.TypeLits
            to ghc-prim:GHC.Types
      
      There was a name clash in GHC.RTS.Flags, where I renamed
      the local type Nat to RtsNat.
      2f6a0ac7
  8. 30 Apr, 2015 2 commits
    • Gabor Greif's avatar
      Typo fixes (mostly in comments) · a3f7517e
      Gabor Greif authored
      a3f7517e
    • Simon Peyton Jones's avatar
      Tidy up treatment of FlexibleContexts · b83160d0
      Simon Peyton Jones authored
      Previously (Trac #10351) we could get
      
          Non type-variable argument in the constraint: C [t]
          (Use FlexibleContexts to permit this)
          When checking that `f' has the inferred type
            f :: forall t. C [t] => t -> ()
      
      which is a bit stupid: we have *inferred* a type that we
      immediately *reject*.  This patch arranges that that the
      generalisation mechanism (TcSimplify.decideQuantification)
      doesn't pick a predicate that will be rejected by the
      subsequent validity check.
      
      This forced some minor refactoring, as usual.
      b83160d0
  9. 29 Apr, 2015 2 commits
    • Simon Peyton Jones's avatar
      Test Trac #10226 · d4a926ba
      Simon Peyton Jones authored
      Fixed by the patch for #10009
      d4a926ba
    • Simon Peyton Jones's avatar
      Improve improvement in the constraint solver · a1275a76
      Simon Peyton Jones authored
      This regrettably-big patch substantially improves the way in which
      "improvement" happens in the constraint solver.  It was triggered by
      trying to crack Trac #10009, but it turned out to solve #10340 as
      well.
      
      The big picture, with several of the trickiest examples, is described
      in Note [The improvement story] in TcInteract.
      
      The major change is this:
      
      * After solving we explicitly try "improvement", by
           - making the unsolved Wanteds into Deriveds
           - allowing Deriveds to rewrite Deriveds
        This more aggressive rewriting "unlocks" some extra
        guess-free unifications.
      
      * The main loop is in TcInteract.solveSimpleWanteds, but I also ended
        up refactoring TcSimplify.simpl_loop, and its surrounding code.
      
        Notably, any insolubles from the Givens are pulled out
        and treated separately, rather than staying in the inert set
        during the solveSimpleWanteds loop.
      
      There are a lot of follow-on changes
      
      * Do not emit generate Derived improvements from Wanteds.
        This saves work in the common case where they aren't needed.
      
      * For improvement we should really do type-class reduction on Derived
        constraints in doTopReactDict.  That entailed changing the GenInst
        constructor a bit; a local and minor change
      
      * Some annoying faffing about with dropping derived constraints;
        see dropDerivedWC, dropDerivedSimples, dropDerivedInsols,
        and their Notes.
      
      * Some substantial refactoring in TcErrors.reportWanteds.
        This work wasn't strictly forced, but I got sucked into it.
        All the changes are in TcErrors.
      
      * Use TcS.unifyTyVar consistently, rather than setWantedTyBind,
        so that unifications are properly tracked.
      
      * Refactoring around solveWantedsTcM, solveWantedsAndDrop.
        They previously guaranteed a zonked result, but it's more
        straightforward for clients to zonk.
      a1275a76
  10. 25 Apr, 2015 1 commit
  11. 24 Apr, 2015 5 commits
  12. 22 Apr, 2015 1 commit