summaryrefslogtreecommitdiff
path: root/compiler/parser/Parser.y.pp
Commit message (Collapse)AuthorAgeFilesLines
...
* A touch more strictness in the parserIan Lynagh2008-01-241-1/+1
|
* Add a bit of strictness to the parserIan Lynagh2008-01-241-1/+1
|
* Add quasi-quotation, courtesy of Geoffrey Mainlandsimonpj@microsoft.com2008-01-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Overview ~~~~~~~~ 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 RnNames.)
* implement prefix unboxed tuples (part of #1509)Isaac Dupree2008-01-021-0/+5
|
* correct type mistake, hidden by happy -agc coercions!Isaac Dupree2007-12-261-1/+1
|
* Implement generalised list comprehensionssimonpj@microsoft.com2007-12-201-24/+64
| | | | | | | | | | | | | | | | | | | | 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 http://hackage.haskell.org/trac/ghc/wiki/SQLLikeComprehensions
* Avoid making Either String an instance of Monad in the Haddock parserDavid Waern2007-11-141-10/+10
|
* Refactor Haddock optionsDavid Waern2007-11-011-23/+15
| | | | | | | | | | | | | | 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.
* View patterns, record wildcards, and record punsDan Licata2007-10-101-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* FIX: parsing of doc optionsDavid Waern2007-10-021-1/+1
| | | | | | | 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. MERGE TO STABLE
* Loosen the syntax of types slightlysimonpj@microsoft.com2007-09-171-1/+1
| | | | | | | | | | | | | | 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.
* Fix CodingStyle#Warnings URLsIan Lynagh2007-09-041-1/+1
|
* Use OPTIONS rather than OPTIONS_GHC for pragmasIan Lynagh2007-09-031-2/+2
| | | | | | | Older GHCs can't parse OPTIONS_GHC. This also changes the URL referenced for the -w options from WorkingConventions#Warnings to CodingStyle#Warnings for the compiler modules.
* Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modulesIan Lynagh2007-09-011-0/+7
|
* Make :i (->) work; fixes trac #1587Ian Lynagh2007-08-171-0/+1
|
* Add a deprecated warning for _scc_Ian Lynagh2007-08-161-1/+3
|
* Change standalone deriving syntax and semantics; fixes trac #1481Ian Lynagh2007-08-101-3/+1
| | | | | You now say deriving instance Cxt => Head
* FIX #1555: Remove "exp -> pat" production in stmtsSimon Marlow2007-07-231-3/+0
| | | | | | | It looks like this was an experiment that accidentally got committed, somewhere between 6.0 and 6.2.
* FIX read040: patterns with type sig on LHS of do-bindingsimonpj@microsoft.com2007-06-211-1/+1
| | | | | | | | | | | | | | 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.
* Add several new record featuresLemmih2007-06-211-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Implementation ~~~~~~~~~~~~~~ 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 RnEnv.lookupRecordBndr RnEnv.lookupConstructorFields 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
* #1318: remove negative-prim-literal old hackish implementationIsaac Dupree2007-05-261-1/+1
|
* Remove the distinction between data and newtype familiesManuel M T Chakravarty2007-05-111-6/+4
| | | | | | | | | - This patch removes "newtype family" declarations. - "newtype instance" declarations can now be instances of data families - This also fixes bug #1331 ** This patch changes the interface format. All libraries and all of ** ** Stage 2 & 3 need to be re-compiled from scratch. **
* FIX: #1253 (Can't use non-layout at top level)Simon Marlow2007-05-071-2/+6
|
* Emit a decent error message when there is a decl-splice inside a decl-bracketsimonpj@microsoft.com2007-03-231-2/+3
| | | | | | | | | | | | | | | | | | 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.
* Fix parsing of parallel array literalsManuel M T Chakravarty2007-02-241-4/+15
|
* Make HsRecordBinds a data type instead of a synonym.lennart@augustsson.net2007-02-041-4/+4
|
* Add support for overloaded string literals.lennart@augustsson.net2006-12-211-1/+4
| | | | | | | | | | 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.
* HsSyn clean up for indexed typesManuel M T Chakravarty2007-01-051-29/+29
| | | | | | | | | | - This patch cleans up the HsSyn representation of type family declarations. - The new representation is not only less delicate, it also simplified teh code a bit. - I took the opportunity of stream lining the terminology and function names at the same time. - I also updated the description on the wiki at <http://hackage.haskell.org/trac/ghc/wiki/TypeFunctionsSyntax>
* Standalone deriving wibbles: keyword is 'derive' not 'derived'; and add flag ↵simonpj@microsoft.com2007-01-021-3/+3
| | | | documentation
* Big tidy-up of deriving codesimonpj@microsoft.com2007-01-021-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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 be 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
* EqPred pretty prints as ~ and equalities without bracketsManuel M T Chakravarty2006-12-291-2/+7
|
* Adding a GENERATED pragmaandy@galois.com2006-12-291-1/+17
| | | | | | | | Adding a {-# GENERATED "SourceFile" SourceSpan #-} <expr> pragma. This will be used to generate coverage for tool generated (or quoted) code. The pragma states the the expression was generated/quoted from the stated source file and source span.
* Parse and desugar equational constraintsManuel M T Chakravarty2006-12-281-1/+2
| | | | | | - With -findexed-types, equational constraints can appear in contexts wherever class predicates are allowed. - The two argument types need to be boxed and rank 0.
* Improve parsing for bang patterns (fixes Trac #1041)simonpj@microsoft.com2006-12-081-18/+25
|
* Kind sigs in associated data/newtype family decls may be omittedManuel M T Chakravarty2006-12-061-27/+89
| | | | | | | * This is only a slight generalisation of the parser, so that family declarations on the toplevel and in classes are uniform. * I didn't allow that right away as it is a bit tricky to avoid reduce/reduce conflicts.
* Add HsUtils.unguardedGRHSs, and use itsimonpj@microsoft.com2006-11-101-2/+2
|
* Module header tidyup #2Simon Marlow2006-10-111-2/+2
| | | | Push this further along, and fix build problems in the first patch.
* Merge Haddock comment support from ghc.haddock -- big patchdavve@dtek.chalmers.se2006-10-051-50/+176
|
* Made 'for' a special ID in the grammar.bjorn@bringert.net2006-09-211-0/+1
|
* Merged stand-alone deriving with FC stuff.bjorn@bringert.net2006-09-201-2/+4
|
* New syntax for stand-alone deriving. Implemented fully.bjorn@bringert.net2006-09-181-0/+11
|
* Added parser and abstract syntax support for stand-alone deriving declarations.bjorn@bringert.net2006-09-171-3/+2
|
* Remove Linear Implicit Parameters, and all their workssimonpj@microsoft.com2006-09-291-4/+1
| | | | | | | Linear implicit parameters have been in GHC quite a while, but we decided they were a mis-feature and scheduled them for removal. This patch does the job.
* Kind sig for toplevel family decls is optionalManuel M T Chakravarty2006-09-201-24/+31
| | | | | | | | | | | | | Mon Sep 18 19:13:47 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Kind sig for toplevel family decls is optional Sat Aug 26 19:03:50 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Kind sig for toplevel family decls is optional - Kind sigs are still compulsory for AT family decls. Changing this is more tricky, as AT decls don't have the family keyword and hence look like empty data decls. That impacts reduce/reduce conflicts and/or the criteria for checking whether a TyData variant is a family signature. - Also removed iso from the syntax (it's still in the lexer in case we want to resurrect it).
* Extend Class.Class to include the TyCons of ATsManuel M T Chakravarty2006-09-201-7/+64
| | | | | | | Mon Sep 18 18:58:51 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Extend Class.Class to include the TyCons of ATs Wed Aug 16 16:15:31 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Extend Class.Class to include the TyCons of ATs
* Type tags in import/export listsManuel M T Chakravarty2006-09-181-4/+12
| | | | | | | Tue Sep 12 16:57:32 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Type tags in import/export lists - To write something like GMapKey(type GMap, empty, lookup, insert) - Requires -findexed-types
* Use family and instance keyword to identify indexed typesManuel M T Chakravarty2006-09-181-54/+75
| | | | | Tue Aug 15 20:16:00 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Use family and instance keyword to identify indexed types
* Remove checkTopTypeDManuel M T Chakravarty2006-09-181-2/+1
| | | | | Tue Aug 15 17:02:53 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Remove checkTopTypeD
* Added error checks & fixed bugsManuel M T Chakravarty2006-09-151-0/+1
| | | | | Thu Aug 3 19:29:38 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Added error checks & fixed bugs
* Revised kind signaturesManuel M T Chakravarty2006-09-151-8/+20
| | | | | Tue Aug 1 14:10:39 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Revised kind signatures