1. 24 Jan, 2008 6 commits
  2. 18 Jan, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Add quasi-quotation, courtesy of Geoffrey Mainland · f3399c44
      simonpj@microsoft.com authored
      This patch adds quasi-quotation, as described in
        "Nice to be Quoted: Quasiquoting for Haskell"
      	(Geoffrey Mainland, Haskell Workshop 2007)
      Implemented by Geoffrey and polished by Simon.
      The syntax for quasiquotation is very similar to the existing
      Template haskell syntax:
      	[$q| stuff |]
      where 'q' is the "quoter".  This syntax differs from the paper, by using
      a '$' rather than ':', to avoid clashing with parallel array comprehensions.
      The "quoter" is a value of type Language.Haskell.TH.Quote.QuasiQuoter, which
      contains two functions for quoting expressions and patterns, respectively.
           quote = Language.Haskell.TH.Quote.QuasiQuoter quoteExp quotePat
           quoteExp :: String -> Language.Haskell.TH.ExpQ
           quotePat :: String -> Language.Haskell.TH.PatQ
      TEXT is passed unmodified to the quoter. The context of the
      quasiquotation statement determines which of the two quoters is
      called: if the quasiquotation occurs in an expression context,
      quoteExp is called, and if it occurs in a pattern context, quotePat
      is called.
      The result of running the quoter on its arguments is spliced into
      the program using Template Haskell's existing mechanisms for
      splicing in code. Note that although Template Haskell does not
      support pattern brackets, with this patch binding occurrences of
      variables in patterns are supported. Quoters must also obey the same
      stage restrictions as Template Haskell; in particular, in this
      example quote may not be defined in the module where it is used as a
      quasiquoter, but must be imported from another module.
      Points to notice
      * The whole thing is enabled with the flag -XQuasiQuotes
      * There is an accompanying patch to the template-haskell library. This
        involves one interface change:
      	currentModule :: Q String
        is replaced by
      	location :: Q Loc
        where Loc is a data type defined in TH.Syntax thus:
            data Loc
              = Loc { loc_filename :: String
      	      , loc_package  :: String
      	      , loc_module   :: String
      	      , loc_start    :: CharPos
      	      , loc_end      :: CharPos }
            type CharPos = (Int, Int)	-- Line and character position
        So you get a lot more info from 'location' than from 'currentModule'.
        The location you get is the location of the splice.
        This works in Template Haskell too of course, and lets a TH program
        generate much better error messages.
      * There's also a new module in the template-haskell package called 
        Language.Haskell.TH.Quote, which contains support code for the
        quasi-quoting feature.
      * Quasi-quote splices are run *in the renamer* because they can build 
        *patterns* and hence the renamer needs to see the output of running the
        splice.  This involved a bit of rejigging in the renamer, especially
        concerning the reporting of duplicate or shadowed names.
        (In fact I found and removed a few calls to checkDupNames in RnSource 
        that are redundant, becuase top-level duplicate decls are handled in
  3. 02 Jan, 2008 1 commit
  4. 26 Dec, 2007 1 commit
  5. 20 Dec, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Implement generalised list comprehensions · 67cb4091
      simonpj@microsoft.com authored
        This patch implements generalised list comprehensions, as described in 
        the paper "Comprehensive comprehensions" (Peyton Jones & Wadler, Haskell
        Workshop 2007).  If you don't use the new comprehensions, nothing
        should change.
        The syntax is not exactly as in the paper; see the user manual entry 
        for details.
        You need an accompanying patch to the base library for this stuff 
        to work.
        The patch is the work of Max Bolingbroke [batterseapower@hotmail.com], 
        with some advice from Simon PJ.
        The related GHC Wiki page is 
  6. 14 Nov, 2007 1 commit
  7. 01 Nov, 2007 1 commit
    • David Waern's avatar
      Refactor Haddock options · 03d8585e
      David Waern authored
      This patch renames the DOC_OPTIONS pragma to OPTIONS_HADDOCK. It also
      adds "-- # ..."-style Haddock option pragmas, for compatibility with
      code that use them.
      Another change is that both of these two pragmas behave like
      OPTIONS_GHC, i.e. they are only allowed at the top of the module, they
      are ignored everywhere else and they are stored in the dynflags. There is
      no longer any Haddock options in HsSyn.
      Please merge this to the 6.8.2 branch when 6.8.1 is out, if appropriate.
  8. 10 Oct, 2007 1 commit
    • Dan Licata's avatar
      View patterns, record wildcards, and record puns · 6a05ec5e
      Dan Licata authored
      This patch implements three new features:
      * view patterns (syntax: expression -> pat in a pattern)
      * working versions of record wildcards and record puns
      See the manual for detailed descriptions.
      Other minor observable changes:
      * There is a check prohibiting local fixity declarations
        when the variable being fixed is not defined in the same let
      * The warn-unused-binds option now reports warnings for do and mdo stmts
      Implementation notes: 
      * The pattern renamer is now in its own module, RnPat, and the
      implementation is now in a CPS style so that the correct context is
      delivered to pattern expressions.
      * These features required a fairly major upheaval to the renamer.
      Whereas the old version used to collect up all the bindings from a let
      (or top-level, or recursive do statement, ...) and put them into scope
      before renaming anything, the new version does the collection as it
      renames.  This allows us to do the right thing with record wildcard
      patterns (which need to be expanded to see what names should be
      collected), and it allows us to implement the desired semantics for view
      patterns in lets.  This change had a bunch of domino effects brought on
      by fiddling with the top-level renaming.
      * Prior to this patch, there was a tricky bug in mkRecordSelId in HEAD,
      which did not maintain the invariant necessary for loadDecl.  See note
      [Tricky iface loop] for details.
  9. 02 Oct, 2007 1 commit
    • David Waern's avatar
      FIX: parsing of doc options · 5ccedd80
      David Waern authored
      Lexing of the doc options pragma was changed, but but no change was 
      made to the parser to reflect that. This patch fixes this problem.
  10. 17 Sep, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Loosen the syntax of types slightly · fa1a55ba
      simonpj@microsoft.com authored
      This change allows you to write
      	f :: (Eq a) => (Ord b) => a -> b -> b
      Previously you could only have a forall and context after '->'
      but not after '=>' which is strange and inconsistent.
      Making the parser a bit more generous didn't change the number
      of shift/reduce conflicts.
      tc236 tests.
  11. 04 Sep, 2007 1 commit
  12. 03 Sep, 2007 1 commit
  13. 01 Sep, 2007 1 commit
  14. 17 Aug, 2007 1 commit
  15. 16 Aug, 2007 1 commit
  16. 10 Aug, 2007 1 commit
  17. 23 Jul, 2007 1 commit
  18. 21 Jun, 2007 2 commits
    • simonpj@microsoft.com's avatar
      FIX read040: patterns with type sig on LHS of do-binding · bb511e2d
      simonpj@microsoft.com authored
      f () = do { x :: Bool <- return True; ... }
      For some reason the production for 'pat' required 'infixexp' on the
      LHS of a do-notation binding.  This patch makes it an 'exp', which 
      thereby allows an expression with a type sig.
      Happily, there are no new shift-reduce errors, so I don't think this
      will break anything else.
    • David Himmelstrup's avatar
      Add several new record features · 2eb04ca0
      David Himmelstrup authored
      1. Record disambiguation (-fdisambiguate-record-fields)
      In record construction and pattern matching (although not
      in record updates) it is clear which field name is intended
      even if there are several in scope.  This extension uses
      the constructor to disambiguate.  Thus
      	C { x=3 }
      uses the 'x' field from constructor C (assuming there is one)
      even if there are many x's in scope.
      2. Record punning (-frecord-puns)
      In a record construction or pattern match or update you can 
      omit the "=" part, thus
      	C { x, y }
      This is just syntactic sugar for
      	C { x=x, y=y }
      3.  Dot-dot notation for records (-frecord-dot-dot)
      In record construction or pattern match (but not update) 
      you can use ".." to mean "all the remaining fields".  So
      	C { x=v, .. }
      means to fill in the remaining fields to give
      	C { x=v, y=y }
      (assuming C has fields x and y).  This might reasonably
      considered very dodgy stuff.  For pattern-matching it brings
      into scope a bunch of things that are not explictly mentioned;
      and in record construction it just picks whatver 'y' is in
      scope for the 'y' field.   Still, Lennart Augustsson really
      wants it, and it's a feature that is extremely easy to explain.
      I thought of using the "parent" field in the GlobalRdrEnv, but
      that's really used for import/export and just isn't right for this.
      For example, for import/export a field is a subordinate of the *type
      constructor* whereas here we need to know what fields belong to a
      particular *data* constructor.
      The main thing is that we need to map a data constructor to its
      fields, and we need to do so in the renamer.   For imported modules
      it's easy: just look in the imported TypeEnv.  For the module being
      compiled, we make a new field tcg_field_env in the TcGblEnv.
      The important functions are
      There is still a significant infelicity in the way the renamer
      works on patterns, which I'll tackle next.
      I also did quite a bit of refactoring in the representation of
      record fields (mainly in HsPat).***END OF DESCRIPTION***
      Place the long patch description above the ***END OF DESCRIPTION*** marker.
      The first line of this file will be the patch name.
      This patch contains the following changes:
      M ./compiler/deSugar/Check.lhs -3 +5
      M ./compiler/deSugar/Coverage.lhs -6 +7
      M ./compiler/deSugar/DsExpr.lhs -6 +13
      M ./compiler/deSugar/DsMeta.hs -8 +8
      M ./compiler/deSugar/DsUtils.lhs -1 +1
      M ./compiler/deSugar/MatchCon.lhs -2 +2
      M ./compiler/hsSyn/Convert.lhs -3 +3
      M ./compiler/hsSyn/HsDecls.lhs -9 +25
      M ./compiler/hsSyn/HsExpr.lhs -13 +3
      M ./compiler/hsSyn/HsPat.lhs -25 +63
      M ./compiler/hsSyn/HsUtils.lhs -3 +3
      M ./compiler/main/DynFlags.hs +6
      M ./compiler/parser/Parser.y.pp -13 +17
      M ./compiler/parser/RdrHsSyn.lhs -16 +18
      M ./compiler/rename/RnBinds.lhs -2 +2
      M ./compiler/rename/RnEnv.lhs -22 +82
      M ./compiler/rename/RnExpr.lhs -34 +12
      M ./compiler/rename/RnHsSyn.lhs -3 +2
      M ./compiler/rename/RnSource.lhs -50 +78
      M ./compiler/rename/RnTypes.lhs -50 +84
      M ./compiler/typecheck/TcExpr.lhs -18 +18
      M ./compiler/typecheck/TcHsSyn.lhs -20 +21
      M ./compiler/typecheck/TcPat.lhs -8 +6
      M ./compiler/typecheck/TcRnMonad.lhs -6 +15
      M ./compiler/typecheck/TcRnTypes.lhs -2 +11
      M ./compiler/typecheck/TcTyClsDecls.lhs -3 +4
      M ./docs/users_guide/flags.xml +7
      M ./docs/users_guide/glasgow_exts.xml +42
  19. 26 May, 2007 1 commit
  20. 11 May, 2007 1 commit
  21. 07 May, 2007 1 commit
  22. 23 Mar, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Emit a decent error message when there is a decl-splice inside a decl-bracket · d52ec21d
      simonpj@microsoft.com authored
      This fixes Trac #1065.  The fix is just to emit a decent error message
      rather than crash.  The situation is this:
        f x = ... [d| $(..stuff..); 
                      f x = v :: T |] ...
      TH wants to rename and typecheck the bracket; but it can't run the 
      nested splice yet.  That seems hard, because we know nothing about v, T,
      which are, presumably bound by the splice.
      The original TH paper says this isn't allowed, and now it's checked for
      properly (in the parser, in fact) rather than causing a crash.  In the
      fullness of time we might want to do something more flexible, but not now.
  23. 24 Feb, 2007 1 commit
  24. 04 Feb, 2007 1 commit
  25. 21 Dec, 2006 1 commit
    • lennart@augustsson.net's avatar
      Add support for overloaded string literals. · 90dc9026
      lennart@augustsson.net authored
      The class is named IsString with the single method fromString.
      Overloaded strings work the same way as overloaded numeric literals.
      In expressions a string literals gets a fromString applied to it.
      In a pattern there will be an equality comparison with the fromString:ed literal.
      Use -foverloaded-strings to enable this extension.
  26. 05 Jan, 2007 1 commit
  27. 02 Jan, 2007 2 commits
    • simonpj@microsoft.com's avatar
    • simonpj@microsoft.com's avatar
      Big tidy-up of deriving code · 84923cc7
      simonpj@microsoft.com authored
      This tidy-up, triggered by Trac #1068, re-factors the way that 'deriving' 
      happens.  It took me way longer than I had intended.  The main changes,
      by far are to TcDeriv; everyting else is a minor consequence.
      While I was at it, I changed the syntax for standalone deriving, so that
      it goes
      	derive instance Show (T a)
      (instead of "derive Show for T").  However, there's still an implicit
      context, generated by the deriving code, and I wonder if it shouldn't really
      	derive instance (..) => Show (T a)
      but I have left it simple for now.
      I also added a function Type.substTyVars, and used it here and there, which
      led to some one-line changes otherwise unrelated (sorry).
      Loose ends:
        * 'deriving Typeable' for indexed data types is still not right
        * standalone deriving should be documented
  28. 29 Dec, 2006 2 commits
  29. 28 Dec, 2006 1 commit
  30. 08 Dec, 2006 1 commit
  31. 06 Dec, 2006 1 commit
  32. 10 Nov, 2006 1 commit