Merge master into the ghc-new-co branch
Final batch of monad-comprehension stuff * 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
More hacking on monad-comp; now works
Preliminary monad-comprehension patch (Trac #4370) 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.
This BIG PATCH contains most of the work for the New Coercion Representation See the paper "Practical aspects of evidence based compilation in System FC" * Coercion becomes a data type, distinct from Type * Coercions become value-level things, rather than type-level things, (although the value is zero bits wide, like the State token) A consequence is that a coerion abstraction increases the arity by 1 (just like a dictionary abstraction) * There is a new constructor in CoreExpr, namely Coercion, to inject coercions into terms
Major refactoring of the type inference engine This patch embodies many, many changes to the contraint solver, which make it simpler, more robust, and more beautiful. But it has taken me ages to get right. The forcing issue was some obscure programs involving recursive dictionaries, but these eventually led to a massive refactoring sweep. Main changes are: * No more "frozen errors" in the monad. Instead "insoluble constraints" are now part of the WantedConstraints type. * The WantedConstraint type is a product of bags, instead of (as before) a bag of sums. This eliminates a good deal of tagging and untagging. * This same WantedConstraints data type is used - As the way that constraints are gathered - As a field of an implication constraint - As both argument and result of solveWanted - As the argument to reportUnsolved * We do not generate any evidence for Derived constraints. They are purely there to allow "impovement" by unifying unification variables. * In consequence, nothing is ever *rewritten* by a Derived constraint. This removes, by construction, all the horrible potential recursive-dictionary loops that were making us tear our hair out. No more isGoodRecEv search either. Hurrah! * We add the superclass Derived constraints during canonicalisation, after checking for duplicates. So fewer superclass constraints are generated than before. * Skolem tc-tyvars no longer carry SkolemInfo. Instead, the SkolemInfo lives in the GivenLoc of the Implication, where it can be tidied, zonked, and substituted nicely. This alone is a major improvement. * Tidying is improved, so that we tend to get t1, t2, t3, rather than t1, t11, t111, etc Moreover, unification variables are always printed with a digit (thus a0, a1, etc), so that plain 'a' is available for a skolem arising from a type signature etc. In this way, (a) We quietly say which variables are unification variables, for those who know and care (b) Types tend to get printed as the user expects. If he writes f :: a -> a f = ...blah... then types involving 'a' get printed with 'a', rather than some tidied variant. * There are significant improvements in error messages, notably in the "Cannot deduce X from Y" messages.
Add rebindable syntax for if-then-else 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
Tidy-up sweep, following the Great Skolemisation Simplification
Super-monster patch implementing the new typechecker -- at last This major patch implements the new OutsideIn constraint solving algorithm in the typecheker, following our JFP paper "Modular type inference with local assumptions". Done with major help from Dimitrios Vytiniotis and Brent Yorgey.
De-polymorphise
fix extraction of command stack of arguments of arrow "forms" (fixes #4236) The command stack was being extracted (by unscramble) with the outermost type first, contrary to the comment on the function.
Trim unused imports detected by new unused-import code
Improve error reporting for non-rigid GADT matches Following suggestions from users, this patch improves the error message when a GADT match needs a rigid type: tcfail172.hs:19:10: GADT pattern match in non-rigid context for `Nil' - Solution: add a type signature + Probable solution: add a type signature for `is_normal' In the pattern: Nil In the definition of `is_normal': is_normal Nil = True Now GHC tries to tell you what to give a type signature *for*. Thanks to Daniel Gorin and others for the suggestions.
Major change in compilation of instance declarations (fix Trac #955, #2328) This patch makes an important change to the way that dictionary functions are handled. Before, they were unconditionally marked INLIINE, but all the code written by the user in the instance was inside that unconditionally-inlined function. Result: massive code bloat in programs that use complicated instances. This patch make instances behave rather as if all the methods were written in separate definitions. That dramatically reduces bloat. The new plan is described in TcInstDcls Note [How instance declarations are translated] Everything validates. The major code-bloat bug is squashed: in particular DoCon is fine now (Trac #2328) and I believe that #955 is also better. Nofib results: Binary sizes -1 s.d. +2.5% +1 s.d. +3.1% Average +2.8% Allocations -1 s.d. -6.4% +1 s.d. +2.5% Average -2.0% Note that 2% improvement. Some programs improve by 20% (rewrite)! Two get slightly worse: pic (2.1%), and gameteb (3.2%), but all others improve or stay the same. I am not absolutely 100% certain that all the corners are correct; for example, when default methods are marked INLINE, are they inlined? But overall it's better. It's nice that the patch also removes a lot of code. I deleted some out of date comments, but there's something like 100 fewer lines of code in the new version! (In the line counts below, there are a lot of new comments.)
Fix Trac #2310: result type signatures are not supported any more We have not supported "result type signatures" for some time, but using one in the wrong way caused a crash. This patch tidies it up.
Make TcArrows warning-free
(F)SLIT -> (f)sLit in TcArrows
Don't import FastString in HsVersions.h Modules that need it import it themselves instead.
Remove GADT refinements, part 3
Remove GADT refinements, part 1 - A while ago, I changed the type checker to use equality constraints together with implication constraints to track local type refinement due to GADT pattern matching. This patch is the first of a number of surgical strikes to remove the resulting dead code of the previous GADT refinement machinery. Hurray to code simplification!