| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.)
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
You now say
deriving instance Cxt => Head
|
|
|
|
|
|
|
| |
It looks like this was an experiment that accidentally got committed,
somewhere between 6.0 and 6.2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
| |
- 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. **
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
- 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>
|
|
|
|
| |
documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
- 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.
|
| |
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
| |
Push this further along, and fix build problems in the first patch.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
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
|
|
|
|
|
| |
Tue Aug 15 17:02:53 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au>
* Remove checkTopTypeD
|
|
|
|
|
| |
Thu Aug 3 19:29:38 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au>
* Added error checks & fixed bugs
|
|
|
|
|
| |
Tue Aug 1 14:10:39 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au>
* Revised kind signatures
|