summaryrefslogtreecommitdiff
path: root/compiler/rename/RnExpr.lhs
Commit message (Collapse)AuthorAgeFilesLines
* Implement -XConstraintKindMax Bolingbroke2011-09-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Fix renaming of guardsSimon Peyton Jones2011-05-091-0/+2
| | | | This was making mc17 fail.
* Do-notation in an arrow context is not rebindableSimon Peyton Jones2011-05-041-3/+18
| | | | Fixes Trac #4851
* Final batch of monad-comprehension stuffSimon Peyton Jones2011-05-041-62/+91
| | | | | | | | * 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-compmonad-compSimon Peyton Jones2011-05-031-66/+28
| | | | | | Lots of refactoring. In particular I have now combined TansformStmt and GroupStmt into a single constructor TransStmt. This gives lots of useful code sharing.
* More on monad-comp; an intermediate state, so don't pullSimon Peyton Jones2011-05-021-47/+49
|
* More hacking on monad-comp; now worksSimon Peyton Jones2011-05-021-125/+100
|
* Simon's hacking on monad-comp; incompleteSimon Peyton Jones2011-04-291-44/+162
|
* Preliminary monad-comprehension patch (Trac #4370)Simon Peyton Jones2011-04-281-38/+85
| | | | | | | | 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.
* Fix Trac #5038 (missing free variable in ifThenElse rebindable syntax)simonpj2011-04-191-7/+4
|
* Ignore names introduced "implicitly" in unused-variable warnings (Fix #4404)wip/T4404Max Bolingbroke2011-04-021-1/+3
| | | | | 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.
* Produce an error message, not a crash, for HsOpApp with non-var operatorsimonpj@microsoft.com2011-01-121-2/+6
| | | | Fixes Trac #4877.
* Tidy up rebindable syntax for MDosimonpj@microsoft.com2010-12-221-39/+15
| | | | | | | | | | | | | | | | | | | | 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
* Fix Trac #4534: renamer bugsimonpj@microsoft.com2010-12-101-1/+3
| | | | | | | | 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.
* Add rebindable syntax for if-then-elsesimonpj@microsoft.com2010-10-221-8/+12
| | | | | | | | | | | 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
* Implement auto-specialisation of imported Idssimonpj@microsoft.com2010-10-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Remove use of lambda with a refutable patternsimonpj@microsoft.com2010-09-231-1/+2
|
* Add separate functions for querying DynFlag and ExtensionFlag optionsIan Lynagh2010-09-181-4/+4
| | | | and remove the temporary DOpt class workaround.
* Separate the language flags from the other DynFlag'sIan Lynagh2010-07-241-1/+1
|
* Make tcg_dus behave more sanely; fixes a mkUsageInfo panicsimonpj@microsoft.com2010-05-061-4/+5
| | | | | | | | | | | | | 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.
* Add a HsExplicitFlag to SpliceDecl, to improve Trac #4042simonpj@microsoft.com2010-05-061-1/+1
| | | | | | | | | | | | | | 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.
* Fix Trac #3943: incorrect unused-variable warningsimonpj@microsoft.com2010-04-121-1/+2
| | | | In fixing this I did the usual little bit of refactoring
* Add commentsimonpj@microsoft.com2010-03-091-0/+1
|
* Refactor part of the renamer to fix Trac #3901simonpj@microsoft.com2010-03-041-157/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Several TH/quasiquote changessimonpj@microsoft.com2010-02-101-12/+21
| | | | | | | | | | | | | | | | | | | | | | 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.
* Fix Trac #3640, plus associated refactoringsimonpj@microsoft.com2009-11-051-10/+9
| | | | | | | | | | | | | 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.
* Add 'rec' to stmts in a 'do', and deprecate 'mdo'simonpj@microsoft.com2009-10-281-95/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Improvements to record puns, wildcardssimonpj@microsoft.com2009-08-201-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Remove GHC's haskell98 dependencyIan Lynagh2009-07-241-3/+1
|
* Add tuple sections as a new featuresimonpj@microsoft.com2009-07-231-5/+17
| | | | | | | | | | | | | | | | 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.
* Remove unused importsIan Lynagh2009-07-071-1/+0
|
* Support for -fwarn-unused-do-bind and -fwarn-wrong-do-bind, as per #3263Max Bolingbroke2009-07-011-2/+2
|
* Template Haskell: allow type splicessimonpj@microsoft.com2009-05-271-2/+2
| | | | | | | | | | | | | | | | | | | | | 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.
* Use return instead of returnM, and similar tidy-upssimonpj@microsoft.com2009-04-091-52/+43
|
* Make some showSDoc's use OneLineMode rather than PageModeIan Lynagh2009-03-311-1/+1
|
* Fix Trac #2713: refactor and tidy up renaming of fixity declssimonpj@microsoft.com2008-10-271-1/+1
| | | | | | | | 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!
* Expunge ThFake, cure Trac #2632simonpj@microsoft.com2008-10-031-24/+9
| | | | | | | | | | | | | | | 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.
* Fix Trac #2490: sections should be parenthesisedsimonpj@microsoft.com2008-08-121-15/+42
| | | | | | | | | | 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.
* Refactoring: define TcRnMonad.failWith and use it in the renamersimonpj@microsoft.com2008-08-121-7/+3
|
* Fix Trac #2506: infix assertsimonpj@microsoft.com2008-08-111-26/+36
|
* Fix the stage 1 buildIan Lynagh2008-05-041-3/+1
|
* Remove a hack from a time when ghc couldn't do seqIan Lynagh2008-05-031-6/+1
|
* Make RnExpr warning-freeIan Lynagh2008-05-031-58/+68
|
* (F)SLIT -> (f)sLit in RnExprIan Lynagh2008-04-121-13/+13
|
* Fix Trac #2188: scoping in TH declarations quotessimonpj@microsoft.com2008-04-041-5/+2
| | | | | | | | | | | | | | | | | | | 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.
* Fix Trac #2136: reporting of unused variablessimonpj@microsoft.com2008-04-031-16/+16
| | | | | | | | | 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.
* Fix Trac #2111: improve error handling for 'rec' in do-notationsimonpj@microsoft.com2008-02-261-57/+66
| | | | | | | | | | | 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.
* Convert more UniqFM's back to LazyUniqFM'sIan Lynagh2008-02-071-1/+1
| | | | | | | | | | | | | | | 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
* Use isEmptyUniqSet rather than isNullUFMIan Lynagh2008-02-051-3/+2
|
* Fix the buildIan Lynagh2008-01-241-0/+22
| | | | | Work around various problems caused by some of the monadification patches not being applied.