1. 18 Nov, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor HsExpr.RecordCon, RecordUpd · 07eb258d
      Simon Peyton Jones authored
      This follows Matthew's patch making pattern synoyms work
      with records.
      
      This patch
       - replaces the (PostTc id [FieldLabel]) field of
         RecordCon with (PostTc id ConLike)
      
       - record-ises both RecordCon and RecordUpd, which
         both have quite a lot of fields.
      
      No change in behaviour
      07eb258d
  2. 17 Nov, 2015 1 commit
  3. 13 Nov, 2015 1 commit
    • Alan Zimmerman's avatar
      APIAnnotations:add Locations in hsSyn for layout · 2290c8bd
      Alan Zimmerman authored
      Summary:
      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
      
      Test Plan: ./validate
      
      Reviewers: hvr, goldfire, bgamari, austin, mpickering
      
      Reviewed By: mpickering
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1370
      
      GHC Trac Issues: #10250
      2290c8bd
  4. 07 Nov, 2015 1 commit
  5. 30 Oct, 2015 2 commits
    • Adam Gundry's avatar
      Disambiguate record selectors by type signature · 0a163741
      Adam Gundry authored
      This makes DuplicateRecordFields more liberal in when it will
      accept ambiguous record selectors, making use of type information in a
      similar way to updates. See Note [Disambiguating record fields] for more
      details. I've also refactored how record updates are disambiguated.
      
      Test Plan: New and amended tests in overloadedrecflds
      
      Reviewers: simonpj, goldfire, bgamari, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1391
      0a163741
    • Simon Peyton Jones's avatar
      Record usage information using GlobalRdrElt · 3e94842d
      Simon Peyton Jones authored
      This patch implements an improvment that I've wanted to do for ages, but
      never gotten around to.
      
      Unused imports are computed based on how imported entities occur (qualified,
      unqualified).   This info was accumulated in tcg_used_rdrnames :: Set RdrName.
      But that was a huge pain, and it got worse when we introduced duplicate
      record fields.
      
      The Right Thing is to record tcg_used_gres :: [GlobalRdrElt], which records
      the GRE *after* filtering with pickGREs.  See Note [GRE filtering] in RdrName.
      This is much, much bette.  This patch deletes quite a bit of code, and is
      conceptually much easier to follow.
      
      Hooray.  There should be no change in functionality.
      3e94842d
  6. 29 Oct, 2015 1 commit
    • Matthew Pickering's avatar
      Record pattern synonyms · 2a74a64e
      Matthew Pickering authored
      This patch implements an extension to pattern synonyms which allows user
      to specify pattern synonyms using record syntax. Doing so generates
      appropriate selectors and update functions.
      
      === Interaction with Duplicate Record Fields ===
      
      The implementation given here isn't quite as general as it could be with
      respect to the recently-introduced `DuplicateRecordFields` extension.
      
      Consider the following module:
      
          {-# LANGUAGE DuplicateRecordFields #-}
          {-# LANGUAGE PatternSynonyms #-}
      
          module Main where
      
          pattern S{a, b} = (a, b)
          pattern T{a}    = Just a
      
          main = do
            print S{ a = "fst", b = "snd" }
            print T{ a = "a" }
      
      In principle, this ought to work, because there is no ambiguity. But at
      the moment it leads to a "multiple declarations of a" error. The problem
      is that pattern synonym record selectors don't do the same name mangling
      as normal datatypes when DuplicateRecordFields is enabled. They could,
      but this would require some work to track the field label and selector
      name separately.
      
      In particular, we currently represent datatype selectors in the third
      component of AvailTC, but pattern synonym selectors are just represented
      as Avails (because they don't have a corresponding type constructor).
      Moreover, the GlobalRdrElt for a selector currently requires it to have
      a parent tycon.
      
      (example due to Adam Gundry)
      
      === Updating Explicitly Bidirectional Pattern Synonyms ===
      
      Consider the following
      
      ```
      pattern Silly{a} <- [a] where
        Silly a = [a, a]
      
      f1 = a [5] -- 5
      
      f2 = [5] {a = 6} -- currently [6,6]
      ```
      
      === Fixing Polymorphic Updates ===
      
      They were fixed by adding these two lines in `dsExpr`. This might break
      record updates but will be easy to fix.
      
      ```
      + ; let req_wrap = mkWpTyApps (mkTyVarTys univ_tvs)
      
      - , pat_wrap = idHsWrapper }
      +, pat_wrap = req_wrap }
      ```
      
      === Mixed selectors error ===
      
      Note [Mixed Record Field Updates]
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Consider the following pattern synonym.
      
          data MyRec = MyRec { foo :: Int, qux :: String }
      
          pattern HisRec{f1, f2} = MyRec{foo = f1, qux=f2}
      
      This allows updates such as the following
      
          updater :: MyRec -> MyRec
          updater a = a {f1 = 1 }
      
      It would also make sense to allow the following update (which we
      reject).
      
          updater a = a {f1 = 1, qux = "two" } ==? MyRec 1 "two"
      
      This leads to confusing behaviour when the selectors in fact refer the
      same field.
      
          updater a = a {f1 = 1, foo = 2} ==? ???
      
      For this reason, we reject a mixture of pattern synonym and normal
      record selectors in the same update block. Although of course we still
      allow the following.
      
          updater a = (a {f1 = 1}) {foo = 2}
      
          > updater (MyRec 0 "str")
          MyRec 2 "str"
      2a74a64e
  7. 19 Oct, 2015 1 commit
  8. 16 Oct, 2015 1 commit
    • Adam Gundry's avatar
      Implement DuplicateRecordFields · b1884b0e
      Adam Gundry authored
      This implements DuplicateRecordFields, the first part of the
      OverloadedRecordFields extension, as described at
      https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields
      
      This includes fairly wide-ranging changes in order to allow multiple
      records within the same module to use the same field names.  Note that
      it does *not* allow record selector functions to be used if they are
      ambiguous, and it does not have any form of type-based disambiguation
      for selectors (but it does for updates). Subsequent parts will make
      overloading selectors possible using orthogonal extensions, as
      described on the wiki pages.  This part touches quite a lot of the
      codebase, and requires changes to several GHC API datatypes in order
      to distinguish between field labels (which may be overloaded) and
      selector function names (which are always unique).
      
      The Haddock submodule has been adapted to compile with the GHC API
      changes, but it will need further work to properly support modules
      that use the DuplicateRecordFields extension.
      
      Test Plan: New tests added in testsuite/tests/overloadedrecflds; these
      will be extended once the other parts are implemented.
      
      Reviewers: goldfire, bgamari, simonpj, austin
      
      Subscribers: sjcjoosten, haggholm, mpickering, bgamari, tibbe, thomie,
      goldfire
      
      Differential Revision: https://phabricator.haskell.org/D761
      b1884b0e
  9. 02 Sep, 2015 1 commit
    • Eric Seidel's avatar
      Use IP based CallStack in error and undefined · 6740d70d
      Eric Seidel authored
      This patch modifies `error`, `undefined`, and `assertError` to use
      implicit call-stacks to provide better error messages to users.
      
      There are a few knock-on effects:
      
      - `GHC.Classes.IP` is now wired-in so it can be used in the wired-in
        types for `error` and `undefined`.
      
      - `TysPrim.tyVarList` has been replaced with a new function
        `TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce
        subtle bugs when you need tyvars of different kinds. The naive
      
        ```
        tv1 = head $ tyVarList kind1
        tv2 = head $ tyVarList kind2
        ```
      
        would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions
        would be applied incorrectly, treating `tv1` and `tv2` as the same
        tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds
        and producing a single tyvar of each kind.
      
      - The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in
        ghc-prim.
      
      - The type `GHC.Exception.ErrorCall` has a new constructor
        `ErrorCallWithLocation` that takes two `String`s instead of one, the
        2nd one being arbitrary metadata about the error (but usually the
        call-stack). A bi-directional pattern synonym `ErrorCall` continues to
        provide the old API.
      
      Updates Cabal, array, and haddock submodules.
      
      Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter,
      liyang, bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D861
      
      GHC Trac Issues: #5273
      6740d70d
  10. 05 Aug, 2015 1 commit
    • Simon Peyton Jones's avatar
      Tidy up and refactor wildcard handling · 95364812
      Simon Peyton Jones authored
      When examining #10615, I found the wildcard handling hard
      to understand.  This patch refactors quite a bit, but with
      no real change in behaviour.
      
       * Split out TcIdSigInfo from TcSigInfo, as a separate type,
         like TcPatSynInfo.
      
       * Make TcIdSigInfo express more invariants by pushing the
         wildard info into TcIdSigBndr
      
       * Remove all special treatment of unification variables that arise
         from wildcards; so the TauTv of TcType.MetaInfo loses its Bool
         argument.
      
      A ton of konck on changes.  The result is significantly simpler, I think.
      95364812
  11. 27 Jul, 2015 1 commit
    • Adam Sandberg Eriksson's avatar
      Implementation of StrictData language extension · f842ad6c
      Adam Sandberg Eriksson authored
      This implements the `StrictData` language extension, which lets the
      programmer default to strict data fields in datatype declarations on a
      per-module basis.
      
      Specification and motivation can be found at
      https://ghc.haskell.org/trac/ghc/wiki/StrictPragma
      
      This includes a tricky parser change due to conflicts regarding `~` in
      the type level syntax: all ~'s are parsed as strictness annotations (see
      `strict_mark` in Parser.y) and then turned into equality constraints at
      the appropriate places using `RdrHsSyn.splitTilde`.
      
      Updates haddock submodule.
      
      Test Plan: Validate through Harbormaster.
      
      Reviewers: goldfire, austin, hvr, simonpj, tibbe, bgamari
      
      Reviewed By: simonpj, tibbe, bgamari
      
      Subscribers: lelf, simonpj, alanz, goldfire, thomie, bgamari, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1033
      
      GHC Trac Issues: #8347
      f842ad6c
  12. 21 Jul, 2015 1 commit
  13. 26 Jun, 2015 2 commits
    • Simon Peyton Jones's avatar
      Treat out-of-scope variables as holes · fb7b6922
      Simon Peyton Jones authored
      This patch implements the idea in Trac #10569.
      
      * An out-of-scope variable is treated as a typed expression
        hole.
      
      * That is, we don't report it in the type checker, not the
        renamer, and we when we do report it, we give its type.
      
      * Moreover, we can defer the error to runtime with
        -fdefer-typed-holes
      
      In implementation terms:
      
      * The renamer turns an unbound variable into a HsUnboundVar
      
      * The type checker emits a Hole constraint for a
        HsUnboundVar, and turns it back into a HsVar
      
      It was a bit painful to implement because a whole raft of
      error messages change slightly.  But there was absolutely
      nothing hard in principle.
      
      Holes are reported with a bunch of possibly-useful context,
      notably the "relevant bindings".  I found that this was
      distracting clutter in the very common case of a mis-typed
      variable that is only accidentally not in scope, so I've
      arranged to print the context information only for true holes,
      that is ones starting with an underscore.
      
      Unbound data constructors use in patterns, like
        f (D x) = x
      are still reportd by the renamer, and abort compilation
      before type checking.
      fb7b6922
    • Simon Peyton Jones's avatar
      Use a Representaional coercion for data families · ff8a6716
      Simon Peyton Jones authored
      When we have
        data instance T (a,b) = MkT a b
      we make a represntation type
        data TPair a b = MkT a b
      plus an axiom to connect the two
        ax a b :: T (a,b)  ~R  TPair a b
      
      Previously this was a Nominal equality, and that worked ok
      but seems illogical since Nominal equalities are between
      types that the programmer thinks of as being equal.  But
      TPair is not visible to the programmer; indeed we call it
      the "representation TyCon".  So a Representational equality
      seems more suitable here.
      ff8a6716
  14. 18 Jun, 2015 1 commit
    • Simon Peyton Jones's avatar
      Rename getCtLoc, setCtLoc · 4a7a6c3a
      Simon Peyton Jones authored
      getCtLoc -> getCtLocM
      setCtLoc -> setCtLocM
      
      These operations are monadic, and I want to introduce a
      pure version of setCtLoc :: Ct -> CtLoc -> Ct
      4a7a6c3a
  15. 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
  16. 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
  17. 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
  18. 11 May, 2015 1 commit
    • 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
  19. 09 May, 2015 2 commits
  20. 06 May, 2015 3 commits
  21. 05 May, 2015 1 commit
  22. 23 Mar, 2015 1 commit
    • eir@cis.upenn.edu's avatar
      Do proper depth checking in the flattener to avoid looping. · c1edbdfd
      eir@cis.upenn.edu authored
      This implements (roughly) the plan put forward in comment:14:ticket:7788,
      fixing #7788, #8550, #9554, #10139, and addressing concerns raised in #10079.
      There are some regressions w.r.t. GHC 7.8, but only with pathological type
      families (like F a = F a). This also (hopefully -- don't have a test case)
      fixes #10158. Unsolved problems include #10184 and #10185, which are both
      known deficiencies of the approach used here.
      
      As part of this change, the plumbing around detecting infinite loops has
      changed. Instead of -fcontext-stack and -ftype-function-depth, we now have
      one combined -freduction-depth parameter. Setting it to 0 disbales the
      check, which is now the recommended way to get (terminating) code to
      typecheck in releases. (The number of reduction steps may well change between
      minor GHC releases!)
      
      This commit also introduces a new IntWithInf type in BasicTypes
      that represents an integer+infinity. This type is used in a few
      places throughout the code.
      
      Tests in
        indexed-types/should_fail/T7788
        indexed-types/should_fail/T8550
        indexed-types/should_fail/T9554
        indexed-types/should_compile/T10079
        indexed-types/should_compile/T10139
        typecheck/should_compile/T10184  (expected broken)
        typecheck/should_compile/T10185  (expected broken)
      
      This commit also changes performance testsuite numbers, for the better.
      c1edbdfd
  23. 10 Feb, 2015 2 commits
    • 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
    • rodlogic's avatar
      Replace .lhs with .hs in compiler comments · 83efb985
      rodlogic authored
      Summary: It looks like during .lhs -> .hs switch the comments were not updated. So doing exactly that.
      
      Reviewers: austin, jstolarek, hvr, goldfire
      
      Reviewed By: austin, jstolarek
      
      Subscribers: thomie, goldfire
      
      Differential Revision: https://phabricator.haskell.org/D621
      
      GHC Trac Issues: #9986
      83efb985
  24. 19 Jan, 2015 1 commit
    • Eric Seidel's avatar
      Expose source locations via Implicit Parameters of type GHC.Location.Location · c024af13
      Eric Seidel authored
      Summary:
      IPs with this type will always be solved for the current source
      location. If another IP of the same type is in scope, the two locations will be
      appended, creating a call-stack. The Location type is kept abstract so users
      cannot create them, but a Location can be turned into a list of SrcLocs, which
      correspond to individual locations in a program. Each SrcLoc contains a
      package/module/file name and start/end lines and columns.
      
      The only thing missing from the SrcLoc in my opinion is the name of the
      top-level definition it inhabits. I suspect that would also be useful, but it's
      not clear to me how to extract the current top-level binder from within the
      constraint solver. (Surely I'm just missing something here?)
      
      I made the (perhaps controversial) decision to have GHC completely ignore
      the names of Location IPs, meaning that in the following code:
      
          bar :: (?myloc :: Location) => String
          bar = foo
      
          foo :: (?loc :: Location) => String
          foo = show ?loc
      
      if I call `bar`, the resulting call-stack will include locations for
      
      1. the use of `?loc` inside `foo`,
      2. `foo`s call-site inside `bar`, and
      3. `bar`s call-site, wherever that may be.
      
      This makes Location IPs very special indeed, and I'm happy to change it if the
      dissonance is too great.
      
      I've also left out any changes to base to make use of Location IPs, since there
      were some concerns about a snowball effect. I think it would be reasonable to
      mark this as an experimental feature for now (it is!), and defer using it in
      base until we have more experience with it. It is, after all, quite easy to
      define your own version of `error`, `undefined`, etc. that use Location IPs.
      
      Test Plan: validate, new test-case is testsuite/tests/typecheck/should_run/IPLocation.hs
      
      Reviewers: austin, hvr, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonmar, rodlogic, carter, thomie
      
      Differential Revision: https://phabricator.haskell.org/D578
      
      GHC Trac Issues: #9049
      c024af13
  25. 16 Jan, 2015 1 commit
    • Alan Zimmerman's avatar
      API Annotations tweaks. · 11881ec6
      Alan Zimmerman authored
      Summary:
      HsTyLit now has SourceText
      
      Update documentation of HsSyn to reflect which annotations are attached to which element.
      
      Ensure that the parser always keeps HsSCC and HsTickPragma values, to
      be ignored in the desugar phase if not needed
      
      Bringing in SourceText for pragmas
      
      Add Location in NPlusKPat
      
      Add Location in FunDep
      
      Make RecCon payload Located
      
      Explicitly add AnnVal to RdrName where it is compound
      
      Add Location in IPBind
      
      Add Location to name in IEThingAbs
      
      Add Maybe (Located id,Bool) to Match to track fun_id,infix
        This includes converting Match into a record and adding a note about why
        the fun_id needs to be replicated in the Match.
      
      Add Location in KindedTyVar
      
      Sort out semi-colons for parsing
      
        - import statements
        - stmts
        - decls
        - decls_cls
        - decls_inst
      
      This updates the haddock submodule.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin, goldfire, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D538
      11881ec6
  26. 08 Jan, 2015 1 commit
    • Simon Peyton Jones's avatar
      Improve HsBang · 9564bb8c
      Simon Peyton Jones authored
      Provoked by questions from Johan
      
       - Improve comments, fix misleading stuff
       - Add commented synonyms for HsSrcBang, HsImplBang, and use them throughout
       - Rename HsUserBang to HsSrcBang
       - Rename dataConStrictMarks to dataConSrcBangs
                dataConRepBangs    to dataConImplBangs
      
      This renaming affects Haddock in a trivial way, hence submodule update
      9564bb8c
  27. 15 Dec, 2014 1 commit
    • Simon Peyton Jones's avatar
      Fix dll-split problem with patch 'Make Core Lint check for locally-bound GlobalId' · 3f87866a
      Simon Peyton Jones authored
      The trouble was that my changes made a lot more files transitively link with
      DynFlags, which is the root module for the revolting Windows dll-split stuff.
      
      Anyway this patch fixes it, in a good way:
      
       - Make GHC/Hooks *not* import DsMonad, because DsMonad imports too
         much other stuff (notably tcLookup variants).  Really, Hooks depends
         only on *types* not *code*.
      
       - To do this I need the DsM type, and the types it depends on,
         not to be part of DsMonad.  So I moved it to TcRnTypes, which is
         where the similar pieces for the TcM and IfM monads live.
      
       - We can then delete DsMonad.hs-boot
      
       - There are a bunch of knock-on change, of no great significance
      3f87866a
  28. 10 Dec, 2014 1 commit
  29. 08 Dec, 2014 1 commit
  30. 03 Dec, 2014 1 commit
  31. 28 Nov, 2014 1 commit
  32. 21 Nov, 2014 3 commits
    • Alan Zimmerman's avatar
      Capture original source for literals · c0ad5bc0
      Alan Zimmerman authored
      Summary:
      Make HsLit and OverLitVal have original source strings, for source to
      source conversions using the GHC API
      
      This is part of the ongoing AST Annotations work, as captured in
      https://ghc.haskell.org/trac/ghc/wiki/GhcAstAnnotations and
      https://ghc.haskell.org/trac/ghc/ticket/9628#comment:28
      
      The motivations for the literals is as follows
      
      ```lang=haskell
      x,y :: Int
      x = 0003
      y = 0x04
      
      s :: String
      s = "\x20"
      
      c :: Char
      c = '\x20'
      
      d :: Double
      d = 0.00
      
      blah = x
        where
          charH = '\x41'#
          intH = 0004#
          wordH = 005##
          floatH = 3.20#
          doubleH = 04.16##
          x = 1
      ```
      
      Test Plan: ./sh validate
      
      Reviewers: simonpj, austin
      
      Reviewed By: simonpj, austin
      
      Subscribers: thomie, goldfire, carter, simonmar
      
      Differential Revision: https://phabricator.haskell.org/D412
      
      GHC Trac Issues: #9628
      c0ad5bc0
    • Alan Zimmerman's avatar
      AST changes to prepare for API annotations, for #9628 · 7927658e
      Alan Zimmerman authored
      Summary:
      AST changes to prepare for API annotations
      
      Add locations to parts of the AST so that API annotations can
      then be added.
      
      The outline of the whole process is captured here
      https://ghc.haskell.org/trac/ghc/wiki/GhcAstAnnotations
      
      This change updates the haddock submodule.
      
      Test Plan: sh ./validate
      
      Reviewers: austin, simonpj, Mikolaj
      
      Reviewed By: simonpj, Mikolaj
      
      Subscribers: thomie, goldfire, carter
      
      Differential Revision: https://phabricator.haskell.org/D426
      
      GHC Trac Issues: #9628
      7927658e
    • Simon Peyton Jones's avatar
      Implement full co/contra-variant subsumption checking (fixes Trac #9569) · b6855422
      Simon Peyton Jones authored
      This is a pretty big patch, but which substantially iproves the subsumption
      check.  Trac #9569 was the presenting example, showing how type inference could
      depend rather delicately on eta expansion.  But there are other less exotic
      examples; see Note [Co/contra-variance of subsumption checking] in TcUnify.
      
      The driving change is to TcUnify.tcSubType.  But also
      
      * HsWrapper gets a new constructor WpFun, which behaves very like CoFun:
             if     wrap1 :: exp_arg <= act_arg
                    wrap2 :: act_res <= exp_res
             then   WpFun wrap1 wrap2 : (act_arg -> arg_res) <= (exp_arg -> exp_res)
      
      * I generalised TcExp.tcApp to call tcSubType on the result,
        rather than tcUnifyType.  I think this just makes it consistent
        with everything else, notably tcWrapResult.
      
      As usual I ended up doing some follow-on refactoring
      
      * AmbigOrigin is gone (in favour of TypeEqOrigin)
      * Combined BindPatSigCtxt and PatSigCxt into one
      * Improved a bit of error message generation
      b6855422