| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Basically as documented in http://hackage.haskell.org/trac/ghc/wiki/KindFact,
this patch adds a new kind Constraint such that:
Show :: * -> Constraint
(?x::Int) :: Constraint
(Int ~ a) :: Constraint
And you can write *any* type with kind Constraint to the left of (=>):
even if that type is a type synonym, type variable, indexed type or so on.
The following (somewhat related) changes are also made:
1. We now box equality evidence. This is required because we want
to give (Int ~ a) the *lifted* kind Constraint
2. For similar reasons, implicit parameters can now only be of
a lifted kind. (?x::Int#) => ty is now ruled out
3. Implicit parameter constraints are now allowed in superclasses
and instance contexts (this just falls out as OK with the new
constraint solver)
Internally the following major changes were made:
1. There is now no PredTy in the Type data type. Instead
GHC checks the kind of a type to figure out if it is a predicate
2. There is now no AClass TyThing: we represent classes as TyThings
just as a ATyCon (classes had TyCons anyway)
3. What used to be (~) is now pretty-printed as (~#). The box
constructor EqBox :: (a ~# b) -> (a ~ b)
4. The type LCoercion is used internally in the constraint solver
and type checker to represent coercions with free variables
of type (a ~ b) rather than (a ~# b)
|
|
|
|
| |
This was making mc17 fail.
|
|
|
|
| |
Fixes Trac #4851
|
|
|
|
|
|
|
|
| |
* Do-notation in arrows is marked with HsStmtContext = ArrowExpr
* tcMDoStmt (which was only used for arrows) is moved
to TcArrows, and renamed tcArrDoStmt
* Improved documentation in the user manual
* Lots of other minor changes
|
|
|
|
|
|
| |
Lots of refactoring. In particular I have now combined
TansformStmt and GroupStmt into a single constructor TransStmt.
This gives lots of useful code sharing.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
This is the work of Nils Schweinsberg <mail@n-sch.de>
It adds the language extension -XMonadComprehensions, which
generalises list comprehension syntax [ e | x <- xs] to work over
arbitrary monads.
|
| |
|
|
|
|
|
| |
We collect variables introduced by the {...} part of a let-like record wildcard
pattern and do not warn if the user then doesn't actually use them.
|
|
|
|
| |
Fixes Trac #4877.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For a long time an 'mdo' expression has had a SyntaxTable
attached to it. However, we're busy deprecating SyntaxTables
in favour of rebindable syntax attached to individual Stmts,
and MDoExpr was totally inconsistent with DoExpr in this
regard.
This patch tidies it all up. Now there's no SyntaxTable on
MDoExpr, and 'modo' is generally handled much more like 'do'.
There is resulting small change in behaviour: now MonadFix is
required only if you actually *use* recursion in mdo. This
seems consistent with the implicit dependency analysis that
is done for mdo.
Still to do:
* Deal with #4148 (this patch is on the way)
* Get rid of the last remaining SyntaxTable on HsCmdTop
|
|
|
|
|
|
|
|
| |
The renamer wasn't attaching the right used-variables to a
TransformStmt constructor.
The real modification is in RnExpr; the rest is just
pretty-printing and white space.
|
|
|
|
|
|
|
|
|
|
|
| |
There are two main changes
* New LANGUAGE option RebindableSyntax, which implies NoImplicitPrelude
* if-the-else becomes rebindable, with function name "ifThenElse"
(but case expressions are unaffected)
Thanks to Sam Anklesaria for doing most of the work here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This big-ish patch arranges that if an Id 'f' is
* Type-class overloaded
f :: Ord a => [a] -> [a]
* Defined with an INLINABLE pragma
{-# INLINABLE f #-}
* Exported from its defining module 'D'
then in any module 'U' that imports D
1. Any call of 'f' at a fixed type will generate
(a) a specialised version of f in U
(b) a RULE that rewrites unspecialised calls to the
specialised on
e.g. if the call is (f Int dOrdInt xs) then the
specialiser will generate
$sfInt :: [Int] -> [Int]
$sfInt = <code for f, imported from D, specialised>
{-# RULE forall d. f Int d = $sfInt #-}
2. In addition, you can give an explicit {-# SPECIALISE -#}
pragma for the imported Id
{-# SPECIALISE f :: [Bool] -> [Bool] #-}
This too generates a local specialised definition,
and the corresponding RULE
The new RULES are exported from module 'U', so that any module
importing U will see the specialised versions of 'f', and will
not re-specialise them.
There's a flag -fwarn-auto-orphan that warns you if the auto-generated
RULES are orphan rules. It's not in -Wall, mainly to avoid lots of
error messages with existing packages.
Main implementation changes
- A new flag on a CoreRule to say if it was auto-generated.
This is persisted across interface files, so there's a small
change in interface file format.
- Quite a bit of fiddling with plumbing, to get the
{-# SPECIALISE #-} pragmas for imported Ids. In particular, a
new field tgc_imp_specs in TcGblEnv, to keep the specialise
pragmas for imported Ids between the typechecker and the desugarer.
- Some new code (although surprisingly little) in Specialise,
to deal with calls of imported Ids
|
| |
|
|
|
|
| |
and remove the temporary DOpt class workaround.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The tcg_dus field used to contain *uses* of type and class decls,
but not *defs*. That was inconsistent, and it really went wrong
for Template Haskell bracket. What happened was that
foo = [d| data A = A
f :: A -> A
f x = x |]
would find a "use" of A when processing the top level of the module,
which in turn led to a mkUsageInfo panic in MkIface. The cause was
the fact that the tcg_dus for the nested quote didn't have defs for
A.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The issue here is that
g :: A -> A
f
data A = A
is treated as if you'd written $(f); that is the call of
f is a top-level Template Haskell splice. This patch
makes sure that we *first* check the -XTemplateHaskellFlag
and bleat about a parse error if it's off. Othewise we
get strange seeing "A is out of scope" errors.
|
|
|
|
| |
In fixing this I did the usual little bit of refactoring
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This one was bigger than I anticipated! The problem was that were
were gathering the binders from a pattern before renaming -- but with
record wild-cards we don't know what variables are bound by C {..}
until after the renamer has filled in the "..".
So this patch does the following
* Change all the collect-X-Binders functions in HsUtils so that
they expect to only be called *after* renaming. That means they
don't need to return [Located id] but just [id]. Which turned out
to be a very worthwhile simplification all by itself.
* Refactor the renamer, and in ptic RnExpr.rnStmt, so that it
doesn't need to use collectLStmtsBinders on pre-renamed Stmts.
* This in turn required me to understand how GroupStmt and
TransformStmts were renamed. Quite fiddly. I rewrote most of it;
result is much shorter.
* In doing so I flattened HsExpr.GroupByClause into its parent
GroupStmt, with trivial knock-on effects in other files.
Blargh.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
a) Added quasi-quote forms for
declarations
types
e.g. f :: [$qq| ... |]
b) Allow Template Haskell pattern quotes (but not splices)
e.g. f x = [p| Int -> $x |]
c) Improve pretty-printing for HsPat to remove superfluous
parens. (This isn't TH related really, but it affects
some of the same code.)
A consequence of (a) is that when gathering and grouping declarations
in RnSource.findSplice, we must expand quasiquotes as we do so.
Otherwise it's all fairly straightforward. I did a little bit of
refactoring in TcSplice.
User-manual changes still to come.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In fixing this bug (to do with record puns), I had the usual rush of
blood to the head, and I did quite a bit of refactoring in the way
that duplicate/shadowed names are reported.
I think the result is shorter as well as clearer.
In one place I found it convenient for the renamer to use the ErrCtxt
carried in the monad. (The renamer used not to have such a context,
but years ago the typechecker and renamer monads became one, so now it
does.) So now it's availble if you want it in future.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The change is this (see Trac #2798). Instead of writing
mdo { a <- getChar
; b <- f c
; c <- g b
; putChar c
; return b }
you would write
do { a <- getChar
; rec { b <- f c
; c <- g b }
; putChar c
; return b }
That is,
* 'mdo' is eliminated
* 'rec' is added, which groups a bunch of statements
into a single recursive statement
This 'rec' thing is already present for the arrow notation, so it
makes the two more uniform. Moreover, 'rec' lets you say more
precisely where the recursion is (if you want to), whereas 'mdo' just
says "there's recursion here somewhere". Lastly, all this works with
rebindable syntax (which mdo does not).
Currently 'mdo' is enabled by -XRecursiveDo. So we now deprecate this
flag, with another flag -XDoRec to enable the 'rec' keyword.
Implementation notes:
* Some changes in Lexer.x
* All uses of RecStmt now use record syntax
I'm still not really happy with the "rec_ids" and "later_ids" in the
RecStmt constructor, but I don't dare change it without consulting Ross
about the consequences for arrow syntax.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Make C { A.a } work with punning, expanding to C { A.a = a }
* Make it so that, with -fwarn-unused-matches,
f (C {..}) = x
does not complain about the bindings introduced by the "..".
* Make -XRecordWildCards implies -XDisambiguateRecordFields.
* Overall refactoring of RnPat, which had become very crufty.
In particular, there is now a monad, CpsRn, private to RnPat,
which deals with the cps-style plumbing. This is why so many
lines of RnPat have changed.
* Refactor the treatment of renaming of record fields into two passes
- rnHsRecFields1, used both for patterns and expressions,
which expands puns, wild-cards
- a local renamer in RnPat for fields in patterns
- a local renamer in RnExpr for fields in construction and update
This make it all MUCH easier to understand
* Improve documentation of record puns, wildcards, and disambiguation
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds tuple sections, so that
(x,,z) means \y -> (x,y,z)
Thanks for Max Bolinbroke for doing the hard work.
In the end, instead of using two constructors in HsSyn, I used
just one (still called ExplicitTuple) whose arguments can be
Present (LHsExpr id)
or Missing PostTcType
While I was at it, I did a bit of refactoring too.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
At last! Trac #1476 and #3177
This patch extends Template Haskell by allowing splices in
types. For example
f :: Int -> $(burble 3)
A type splice should work anywhere a type is expected. This feature
has been long requested, and quite a while ago I'd re-engineered the
type checker to make it easier, but had never got around to finishing
the job. With luck, this does it.
There's a ToDo in the HsSpliceTy case of RnTypes.rnHsType, where I
am not dealing properly with the used variables; but that's awaiting
the refactoring of the way we report unused names.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
In fixing #2713, this patch also eliminates two almost-unused
functions from RnEnv (lookupBndr and lookupBndr_maybe). The
net lines of code is prety much unchanged, but more of them
are comments!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch fixes a dirty hack (the fake ThFake module), which in turn
was causing Trac #2632.
The new scheme is that the top-level binders in a TH [d| ... |] decl splice
get Internal names. That breaks a previous invariant that things like
TyCons always have External names, but these TyCons are never long-lived;
they live only long enough to typecheck the TH quotation; the result is
discarded. So it seems cool.
Nevertheless -- Template Haskell folk: please test your code. The testsuite
is OK but it's conceivable that I've broken something in TH. Let's see.
|
|
|
|
|
|
|
|
|
|
| |
When I added bang patterns I had to slightly generalise where the
parser would recognise sections. See Note [Parsing sections] in
parser.y.pp.
I forgot to check that ordinary H98 sections obey the original
rules. This patch adds the check.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch fixes a rather tiresome issue, namely the fact that
a TH declaration quote *shadows* bindings in outer scopes:
f g = [d| f :: Int
f = g
g :: Int
g = 4 |]
Here, the outer bindings for 'f' (top-level) and 'g' (local)
are shadowed, and the inner bindings for f,g should not be
reported as duplicates. (Remember they are top-level bindings.)
The actual bug was that we'd forgotten to delete 'g' from the
LocalRdrEnv, so the type sig for 'g' was binding to the outer
'g' not the inner one.
|
|
|
|
|
|
|
|
|
| |
There's a bit of a hack RnBinds.rnValBindsAndThen, documented
in Note [Unused binding hack]. But the hack was over brutal
before, and produced unnecssarily bad (absence of) warnings.
This patch does a bit of refactoring; and fixes the bug in
rnValBindsAndThen.
|
|
|
|
|
|
|
|
|
|
|
| |
We were not dealing correctly with all the combinations of
do notation
mdo notation
arrow notation
in combination with 'rec' Stmts.
I think this patch sorts it out.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These fix these failures:
break008(ghci)
break009(ghci)
break026(ghci)
ghci.prog009(ghci)
ghci025(ghci)
print007(ghci)
prog001(ghci)
prog002(ghci)
prog003(ghci)
at least some of which have this symptom:
Exception: expectJust prune
|
| |
|
|
|
|
|
| |
Work around various problems caused by some of the monadification patches
not being applied.
|