1. 01 Jun, 2015 1 commit
    • Alan Zimmerman's avatar
      ApiAnnotations : strings in warnings do not return SourceText · e6191d1c
      Alan Zimmerman authored
      Summary:
      The strings used in a WARNING pragma are captured via
      
          strings :: { Located ([AddAnn],[Located FastString]) }
              : STRING { sL1 $1 ([],[L (gl $1) (getSTRING $1)]) }
          ..
      
      The STRING token has a method getSTRINGs that returns the original
      source text for a string.
      
      A warning of the form
      
          {-# WARNING Logic
                    , mkSolver
                    , mkSimpleSolver
                    , mkSolverForLogic
                    , solverSetParams
                    , solverPush
                    , solverPop
                    , solverReset
                    , solverGetNumScopes
                    , solverAssertCnstr
                    , solverAssertAndTrack
                    , solverCheck
                    , solverCheckAndGetModel
                    , solverGetReasonUnknown
                    "New Z3 API support is still incomplete and fragile: \
                    \you may experience segmentation faults!"
            #-}
      
      returns the concatenated warning string rather than the original source.
      
      This patch now deals with all remaining instances of getSTRING to bring
      in a SourceText for each.
      
      This updates the haddock submodule as well, for the AST change.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin, goldfire
      
      Reviewed By: austin
      
      Subscribers: bgamari, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D907
      
      GHC Trac Issues: #10313
      e6191d1c
  2. 27 May, 2015 1 commit
    • Alan Zimmerman's avatar
      ApiAnnotations tweaks · c5911479
      Alan Zimmerman authored
      Summary:
      A collection of minor updates for the API Annotations.
      
      1. The annotations for the implicity parameter is disconnected in the
         following
      
          type MPI = ?mpi_secret :: MPISecret
      
      2. In the following, the annotation for one of the commas is disconeected.
      
          mkPoli = mkBila . map ((,,(),,()) <$> P.base <*> P.pos <*> P.form)
      
      3. In the following, the annotation for the parens becomes disconnected
      
          data MaybeDefault v where
              SetTo :: forall v . ( Eq v, Show v ) => !v -> MaybeDefault v
              SetTo4 :: forall v a. (( Eq v, Show v ) => v -> MaybeDefault v
                                                      -> a -> MaybeDefault [a])
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: bgamari, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D901
      
      GHC Trac Issues: #10399
      c5911479
  3. 21 May, 2015 3 commits
  4. 18 May, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor tuple constraints · ffc21506
      Simon Peyton Jones authored
      Make tuple constraints be handled by a perfectly ordinary
      type class, with the component constraints being the
      superclasses:
          class (c1, c2) => (c2, c2)
      
      This change was provoked by
      
        #10359  inability to re-use a given tuple
                constraint as a whole
      
        #9858   confusion between term tuples
                and constraint tuples
      
      but it's generally a very nice simplification. We get rid of
       -  In Type, the TuplePred constructor of PredTree,
          and all the code that dealt with TuplePreds
       -  In TcEvidence, the constructors EvTupleMk, EvTupleSel
      
      See Note [How tuples work] in TysWiredIn.
      
      Of course, nothing is ever entirely simple. This one
      proved quite fiddly.
      
      - I did quite a bit of renaming, which makes this patch
        touch a lot of modules. In partiuclar tupleCon -> tupleDataCon.
      
      - I made constraint tuples known-key rather than wired-in.
        This is different to boxed/unboxed tuples, but it proved
        awkward to have all the superclass selectors wired-in.
        Easier just to use the standard mechanims.
      
      - While I was fiddling with known-key names, I split the TH Name
        definitions out of DsMeta into a new module THNames.  That meant
        that the known-key names can all be gathered in PrelInfo, without
        causing module loops.
      
      - I found that the parser was parsing an import item like
            T( .. )
        as a *data constructor* T, and then using setRdrNameSpace to
        fix it.  Stupid!  So I changed the parser to parse a *type
        constructor* T, which means less use of setRdrNameSpace.
      
        I also improved setRdrNameSpace to behave better on Exact Names.
        Largely on priciple; I don't think it matters a lot.
      
      - When compiling a data type declaration for a wired-in thing like
        tuples (,), or lists, we don't really need to look at the
        declaration.  We have the wired-in thing!  And not doing so avoids
        having to line up the uniques for data constructor workers etc.
        See Note [Declarations for wired-in things]
      
      - I found that FunDeps.oclose wasn't taking superclasses into
        account; easily fixed.
      
      - Some error message refactoring for invalid constraints in TcValidity
      
      - Haddock needs to absorb the change too; so there is a submodule update
      ffc21506
  5. 14 May, 2015 1 commit
    • Austin Seipp's avatar
      Revert multiple commits · 3cf8ecdc
      Austin Seipp authored
      This reverts multiple commits from Simon:
      
        - 04a484ea Test Trac #10359
        - a9ccd37a Test Trac #10403
        - c0aae6f6 Test Trac #10248
        - eb6ca851 Make the "matchable-given" check happen first
        - ca173aa3 Add a case to checkValidTyCon
        - 51cbad15 Update haddock submodule
        - 6e1174da Separate transCloVarSet from fixVarSet
        - a8493e03 Fix imports in HscMain (stage2)
        - a154944b Two wibbles to fix the build
        - 5910a1bc Change in capitalisation of error msg
        - 130e93aa Refactor tuple constraints
        - 8da785d5 Delete commented-out line
      
      These break the build by causing Haddock to fail mysteriously when
      trying to examine GHC.Prim it seems.
      3cf8ecdc
  6. 13 May, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor tuple constraints · 130e93aa
      Simon Peyton Jones authored
      Make tuple constraints be handled by a perfectly ordinary
      type class, with the component constraints being the
      superclasses:
          class (c1, c2) => (c2, c2)
      
      This change was provoked by
      
        #10359  inability to re-use a given tuple
                constraint as a whole
      
        #9858   confusion between term tuples
                and constraint tuples
      
      but it's generally a very nice simplification. We get rid of
       -  In Type, the TuplePred constructor of PredTree,
          and all the code that dealt with TuplePreds
       -  In TcEvidence, the constructors EvTupleMk, EvTupleSel
      
      See Note [How tuples work] in TysWiredIn.
      
      Of course, nothing is ever entirely simple. This one
      proved quite fiddly.
      
      - I did quite a bit of renaming, which makes this patch
        touch a lot of modules. In partiuclar tupleCon -> tupleDataCon.
      
      - I made constraint tuples known-key rather than wired-in.
        This is different to boxed/unboxed tuples, but it proved
        awkward to have all the superclass selectors wired-in.
        Easier just to use the standard mechanims.
      
      - While I was fiddling with known-key names, I split the TH Name
        definitions out of DsMeta into a new module THNames.  That meant
        that the known-key names can all be gathered in PrelInfo, without
        causing module loops.
      
      - I found that the parser was parsing an import item like
            T( .. )
        as a *data constructor* T, and then using setRdrNameSpace to
        fix it.  Stupid!  So I changed the parser to parse a *type
        constructor* T, which means less use of setRdrNameSpace.
      
        I also improved setRdrNameSpace to behave better on Exact Names.
        Largely on priciple; I don't think it matters a lot.
      
      - When compiling a data type declaration for a wired-in thing like
        tuples (,), or lists, we don't really need to look at the
        declaration.  We have the wired-in thing!  And not doing so avoids
        having to line up the uniques for data constructor workers etc.
        See Note [Declarations for wired-in things]
      
      - I found that FunDeps.oclose wasn't taking superclasses into
        account; easily fixed.
      
      - Some error message refactoring for invalid constraints in TcValidity
      130e93aa
  7. 11 May, 2015 5 commits
    • 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
    • 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
  8. 08 May, 2015 2 commits
  9. 07 May, 2015 1 commit
    • 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
  10. 06 May, 2015 6 commits
  11. 04 May, 2015 1 commit
    • 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
  12. 14 Apr, 2015 5 commits
  13. 10 Apr, 2015 1 commit
  14. 07 Apr, 2015 2 commits
  15. 03 Apr, 2015 1 commit
  16. 02 Apr, 2015 1 commit
  17. 30 Mar, 2015 1 commit
  18. 21 Mar, 2015 1 commit
  19. 07 Mar, 2015 1 commit
  20. 06 Mar, 2015 1 commit
  21. 10 Feb, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor the handling of quasi-quotes · f46360ed
      Simon Peyton Jones authored
      As Trac #10047 points out, a quasi-quotation [n|...blah...|] is supposed
      to behave exactly like $(n "...blah...").  But it doesn't!  This was outright
      wrong: quasiquotes were being run even inside brackets.
      
      Now that TH supports both typed and untyped splices, a quasi-quote is properly
      regarded as a particular syntax for an untyped splice. But apart from that
      they should be treated the same.  So this patch refactors the handling of
      quasiquotes to do just that.
      
      The changes touch quite a lot of files, but mostly in a routine way.
      The biggest changes by far are in RnSplice, and more minor changes in
      TcSplice.  These are the places where there was real work to be done.
      Everything else is routine knock-on changes.
      
      * No more QuasiQuote forms in declarations, expressions, types, etc.
        So we get rid of these data constructors
          * HsBinds.QuasiQuoteD
          * HsExpr.HsSpliceE
          * HsPat.QuasiQuotePat
          * HsType.HsQuasiQuoteTy
      
      * We get rid of the HsQuasiQuote type altogether
      
      * Instead, we augment the HsExpr.HsSplice type to have three
        consructors, for the three types of splice:
          * HsTypedSplice
          * HsUntypedSplice
          * HsQuasiQuote
        There are some related changes in the data types in HsExpr near HsSplice.
        Specifically: PendingRnSplice, PendingTcSplice, UntypedSpliceFlavour.
      
      * In Hooks, we combine rnQuasiQuoteHook and rnRnSpliceHook into one.
        A smaller, clearer interface.
      
      * We have to update the Haddock submodule, to accommodate the hsSyn changes
      f46360ed
  22. 05 Feb, 2015 1 commit
  23. 20 Jan, 2015 1 commit