summaryrefslogtreecommitdiff
path: root/compiler/deSugar/Check.lhs
Commit message (Collapse)AuthorAgeFilesLines
* More hacking on monad-compmonad-compSimon Peyton Jones2011-05-031-728/+730
| | | | | | Lots of refactoring. In particular I have now combined TansformStmt and GroupStmt into a single constructor TransStmt. This gives lots of useful code sharing.
* Remove the now-unused constructor VarPatOutsimonpj@microsoft.com2010-11-051-2/+1
|
* Improve the recent changes to overlap-checking for view patterssimonpj@microsoft.com2009-08-101-88/+104
| | | | | | | | | The previous patch simply gave up for view patterns; this version instead treats them like n+k patterns and gives signficantly better results. Less code, too.
* Minor refactoringIan Lynagh2009-08-091-2/+2
|
* FIX #2395 (ViewPatterns trigger bad Check errors)Alexander Dunlap2009-08-071-3/+5
|
* Take account of GADTs when reporting patterm-match overlapsimonpj@microsoft.com2009-07-221-6/+9
| | | | | | | | | | | | | | | | | | | | | When matching against a GADT, some of the constructors may be impossible. For example data T a where T1 :: T Int T2 :: T Bool T3 :: T a f :: T Int -> Int f T1 = 3 f T3 = 4 Here, does not have any missing cases, despite omittting T2, because T2 :: T Bool. This patch teaches the overlap checker about GADTs, which happily turned out to be rather easy even though the overlap checker needs a serious rewrite.
* Fix Trac #2246; overhaul handling of overloaded literalssimonpj@microsoft.com2008-05-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | The real work of fixing Trac #2246 is to use shortCutLit in MatchLit.dsOverLit, so that type information discovered late in the day by the type checker can still be exploited during desugaring. However, as usual I found myself doing some refactoring along the way, to tidy up the handling of overloaded literals. The main change is to split HsOverLit into a record, which in turn uses a sum type for the three variants. This makes the code significantly more modular. data HsOverLit id = OverLit { ol_val :: OverLitVal, ol_rebindable :: Bool, -- True <=> rebindable syntax -- False <=> standard syntax ol_witness :: SyntaxExpr id, -- Note [Overloaded literal witnesses] ol_type :: PostTcType } data OverLitVal = HsIntegral !Integer -- Integer-looking literals; | HsFractional !Rational -- Frac-looking literals | HsIsString !FastString -- String-looking literals
* (F)SLIT -> (f)sLit in DsUtilsIan Lynagh2008-04-121-1/+1
|
* Fixed warnings in deSugar/Check, except for incomplete pattern matchesTwan van Laarhoven2008-02-031-26/+36
|
* View patterns, record wildcards, and record punsDan Licata2007-10-101-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 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
|
* Add several new record featuresLemmih2007-06-211-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Remove the unused HsExpr constructor DictPatLemmih2007-06-181-10/+1
|
* Store a SrcSpan instead of a SrcLoc inside a NameSimon Marlow2007-05-111-1/+1
| | | | This has been a long-standing ToDo.
* Warning fix for unused and redundant importsMichael D. Adams2007-05-101-1/+0
|
* Add more assertionssimonpj@microsoft.com2007-05-021-3/+3
|
* Add support for overloaded string literals.lennart@augustsson.net2006-12-211-0/+1
| | | | | | | | | | 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.
* Module header tidyup, phase 1Simon Marlow2006-10-111-19/+14
| | | | | | | | | | | | This patch is a start on removing import lists and generally tidying up the top of each module. In addition to removing import lists: - Change DATA.IOREF -> Data.IORef etc. - Change List -> Data.List etc. - Remove $Id$ - Update copyrights - Re-order imports to put non-GHC imports last - Remove some unused and duplicate imports
* Merge Haddock comment support from ghc.haddock -- big patchdavve@dtek.chalmers.se2006-10-051-2/+2
|
* Fix newtype deriving properly (un-doing Audreys patch)simonpj@microsoft.com2006-09-251-6/+6
| | | | | | | | | | | | | | | | | | | | The newtype-deriving mechanism generates a HsSyn case expression looking like this case (d `cast` co) of { ... } That is, the case expression scrutinises a dictionary. This is otherwise never seen in HsSyn, and it made the desugarer (Check.get_unused_cons) crash in tcTyConAppTyCon. It would really be better to generate Core in TcInstDecls (the newtype deriving part) but I'm not going to do that today. Instead, I made Check.get_unused_cons a bit more robust. Audrey tried to fix this over the weekend, but her fix was, alas, utterly bogus, which caused mysterious failures later. I completely undid this change. Anyway it should work now!
* Fix pattern w/o location in CheckManuel M T Chakravarty2006-08-071-1/+1
|
* Add CoPat stuffManuel M T Chakravarty2006-08-061-0/+2
| | | | Wed Jul 19 09:55:27 EDT 2006 kevind@bu.edu
* Massive patch for the first months work adding System FC to GHC #10Manuel M T Chakravarty2006-08-041-40/+36
| | | | | | | | Broken up massive patch -=chak Original log message: This is (sadly) all done in one patch to avoid Darcs bugs. It's not complete work... more FC stuff to come. A compiler using just this patch will fail dismally.
* Lazy patterns are like wild-cards for overlap warningssimonpj@microsoft.com2006-07-271-1/+2
| | | | | | | | MERGE TO STABLE Fixes Trac #827 Test is should_compiler/ds058
* Reorganisation of the source treeSimon Marlow2006-04-071-0/+698
Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.