1. 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
  2. 13 Jan, 2015 1 commit
    • GregWeber's avatar
      add -th-file which generates a th.hs file · 07ace5c2
      GregWeber authored
      Summary:
      see Trac #8624
      
      similar functionality is now available
      with -ddump-to-file -ddump-splices
      
      However, users are already accustomed to -ddump-splices
      having a particular format, and this format is not completely valid code
      The goal of -th-file is to dump valid Haskell code
      
      Additionally, the convention of -ddump-to-file is to name the file after
      the flag, so the file is .dump-splices
      Given that the goal of the new flag is to generate valid Haskell,
      The extension should be .hs
      
      Additionally, -ddump-to-file effects all other dump flags
      
      Test Plan:
      look at the output of using the -th-file flag
      and compare it to the output of using -ddump-to-file and -ddump-splices
      I want to add test cases, but just need some pointers on getting started there
      
      Reviewers: thomie, goldfire, simonpj, austin
      
      Reviewed By: simonpj, austin
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D518
      
      GHC Trac Issues: #8624
      07ace5c2
  3. 03 Dec, 2014 1 commit
  4. 27 Nov, 2014 1 commit
  5. 21 Nov, 2014 1 commit
    • eir@cis.upenn.edu's avatar
      Fix #1476 by making splice patterns work. · 2346de44
      eir@cis.upenn.edu authored
      Unfortunately, splice patterns in brackets still do not work
      because we don't run splices in brackets. Without running a pattern
      splice, we can't know what variables it binds, so we're stuck.
      
      This is still a substantial improvement, and it may be the best
      we can do. Still must document new behavior.
      2346de44
  6. 04 Nov, 2014 1 commit
  7. 02 Nov, 2014 1 commit
  8. 06 Sep, 2014 1 commit
  9. 15 May, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Add LANGUAGE pragmas to compiler/ source files · 23892440
      Herbert Valerio Riedel authored
      In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
      reorganized, while following the convention, to
      
      - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
        any `{-# OPTIONS_GHC #-}`-lines.
      
      - Moreover, if the list of language extensions fit into a single
        `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
        line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
        individual language extension. In both cases, try to keep the
        enumeration alphabetically ordered.
        (The latter layout is preferable as it's more diff-friendly)
      
      While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
      occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
      23892440
  10. 08 Jan, 2014 1 commit
  11. 27 Dec, 2013 1 commit
    • Edsko de Vries's avatar
      Add hook for splicing in renamer · df2dd64d
      Edsko de Vries authored
      With the recent modifications to the TH infrastructure, many splices are now
      expanded in the renamer rather than the typechecker. This means that tools
      which inspect the renamed tree don't get to see the original splices. Added a
      new hook which gets called before such a splice gets expanded, analogous to the
      runQuasiQuoteHook.
      df2dd64d
  12. 27 Nov, 2013 1 commit
  13. 25 Nov, 2013 1 commit
    • Simon Peyton Jones's avatar
      Another raft of Template Haskell clean-up · 51deeb0d
      Simon Peyton Jones authored
      The handling of typed and untyped brackets was extremely convoluted,
      partly because of the evolutionary history.  I've tidied it all up.
      
      See Note [How brackets and nested splices are handled] in TcSplice
      for the full story
      
      Main changes:
      
       * Untyped brackets: after the renamer, HsRnBracketOut carries
         PendingRnSplices for splices in untyped brackets.  In the
         typechecker, these pending splices are typechecked quite
         straigtforwardly, with no ps_var nonsense.
      
       * Typed brackets: after the renamer typed brackest still look
         like HsBracket. The type checker does the ps_var thing.
      
       * In TcRnTypes.ThStage, the Brack constructor, we distinguish
         the renaming from typehecking pending-stuff.  Much more
         perspicuous!
      
       * The "typed" flag is in HsSpliceE, not in HsSplice, because
         only expressions can be typed.  Patterns, types, declarations
         cannot.
      
      There is further improvement to be done to make the handling of
      declaration splices more uniform.
      51deeb0d
  14. 22 Nov, 2013 2 commits
    • Simon Peyton Jones's avatar
      ea49c015
    • Simon Peyton Jones's avatar
      A raft of changes driven by Trac #8540 · 78814882
      Simon Peyton Jones authored
      The root cause of #8450 is that the new Template Haskell story, with
      the renamer doing more of the work of Template Haskell, wasn't dealing
      correctly with the keepAlive problem.  Consider
          g = ..blah...
          f = [| g |]
      Then f's RHS refers to g's name but not to g, so g was being discarded
      as dead code.
      
      Fixing this sucked me into a deep swamp of understanding how all the moving
      parts of hte new Template Haskell fit together, leading to a large collection
      of related changes and better documentation.  Specifically:
      
      * Instead of putting the TH level of a binder in the LocalRdrEnv, there
        is now a separate field
            tcl_th_bndrs :: NameEnv (TopLevelFlag, ThLevel)
        in the TcLclEnv, which records for each binder
           a) whether it is syntactically a top-level binder or not
           b) its TH level
        This deals uniformly with top-level and non-top-level binders, which was
        previously dealt with via greviously-delicate meddling with Internal and
        External Names.  Much better.
      
      * As a result I could remove the tct_level field of ATcId.
      
      * There are consequential changes in TcEnv too, which must also extend the
        level bindings.  Again, more clarity.
      
        I renamed TcEnv.tcExtendTcTyThingEnv to tcExtendKindEnv2, since it's only used
        during kind inference, for (AThing kind) and APromotionErr; and that is
        relevant to whether we want to extend the tcl_th_bndrs field (no).
      
      * I de-crufted the code in RnEnv.extendGlobalRdrEnv, by getting rid of the
        qual_gre code which said "Seems like 5 times as much work as it deserves!".
        Instead, RdrName.pickGREs makes the Internal names shadow External ones.
      
      * I moved the checkThLocalName cross-stage test to finishHsVar; previously
        we weren't doing the test at all in the OpApp case!
      
      * Quite a few changes (shortening the code) in the cross-stage checking code
        in TcExpr and RnSplice, notably to move the keepAlive call to the renamer
      
      One leftover piece:
      
      * In TcEnv I removed tcExtendGhciEnv and refactored
        tcExtendGlobalTyVars; this is really related to the next commit, but
        it was too hard to disentangle.
      78814882
  15. 06 Nov, 2013 1 commit
  16. 04 Oct, 2013 8 commits