- 03 Nov, 2004 1 commit
-
-
igloo authored
Implement TH ForallC constructor.
-
- 08 Oct, 2004 1 commit
-
-
simonpj authored
HsNoBang should simply be omitted; fixes a TH_spliceDecl2 test
-
- 01 Oct, 2004 1 commit
-
-
simonpj authored
Allow kind signatures in GADT data type declarations
-
- 30 Sep, 2004 1 commit
-
-
simonpj authored
------------------------------------ Add Generalised Algebraic Data Types ------------------------------------ This rather big commit adds support for GADTs. For example, data Term a where Lit :: Int -> Term Int App :: Term (a->b) -> Term a -> Term b If :: Term Bool -> Term a -> Term a ..etc.. eval :: Term a -> a eval (Lit i) = i eval (App a b) = eval a (eval b) eval (If p q r) | eval p = eval q | otherwise = eval r Lots and lots of of related changes throughout the compiler to make this fit nicely. One important change, only loosely related to GADTs, is that skolem constants in the typechecker are genuinely immutable and constant, so we often get better error messages from the type checker. See TcType.TcTyVarDetails. There's a new module types/Unify.lhs, which has purely-functional unification and matching for Type. This is used both in the typechecker (for type refinement of GADTs) and in Core Lint (also for type refinement).
-
- 01 Jun, 2004 1 commit
-
-
igloo authored
Add missing functions to TH export list (mostly spotted by Duncan Coutts). Update TH test output. Add TH support for patterns with type signatures, and test for same (requested by Isaac Jones). Add TH support for pattern guards, and tests for same (requested by Isaac Jones). Add infix patterns to TH datatypes. Added Lift instances for 2- to 7-tuples (requested by Duncan Coutts).
-
- 21 Apr, 2004 1 commit
-
-
simonpj authored
In Template Haskell suppport dyn "M.x" to mean "look up the qualified name M.x in the environment", which is what you'd expect. George Russel wanted this.
-
- 05 Apr, 2004 1 commit
-
-
simonpj authored
Remove the entirely-redundant location from the argument of constructor HsPredTy, so that we have HsPredTy HsType rather than HsPredTy LHsType
-
- 02 Apr, 2004 1 commit
-
-
simonpj authored
Another stage-2 wibble to last commit
-
- 17 Mar, 2004 1 commit
-
-
simonpj authored
------------------------ More newtype clearing up ------------------------ * Change the representation of TyCons so that it accurately reflects * data (0 or more constrs) * newtype (1 constr) * abstract (unknown) Replaces DataConDetails and AlgTyConFlavour with AlgTyConRhs * Add IfaceSyn.IfaceConDecls, a kind of stripped-down analogue of AlgTyConRhs * Move NewOrData from BasicTypes to HsDecl (it's now an HsSyn thing) * Arrange that Type.newTypeRep and splitRecNewType_maybe unwrap just one layer of new-type-ness, leaving the caller to recurse. This still leaves typeRep and repType in Type.lhs; these functions are still vaguely disturbing and probably should get some attention. Lots of knock-on changes. Fixes bug in ds054.
-
- 05 Jan, 2004 2 commits
- 04 Jan, 2004 1 commit
-
-
igloo authored
Split the pretty-printer out - pprint will now give you pretty much anything you are likely to want to pretty-print as a String. For a Doc you need (to_HPJ_Doc . ppr), which could be made nicer if it is widely used. Also took the opportunity to do a bit of module renaming and fixed the odd typo here and there.
-
- 16 Dec, 2003 1 commit
-
-
simonpj authored
-------------------- Towards type splices -------------------- Starts the move to supporting type splices, by making HsExpr.HsSplice a separate type of its own, and adding HsSpliceTy constructor to HsType.
-
- 10 Dec, 2003 1 commit
-
-
simonmar authored
Add accurate source location annotations to HsSyn ------------------------------------------------- Every syntactic entity in HsSyn is now annotated with a SrcSpan, which details the exact beginning and end points of that entity in the original source file. All honest compilers should do this, and it was about time GHC did the right thing. The most obvious benefit is that we now have much more accurate error messages; when running GHC inside emacs for example, the cursor will jump to the exact location of an error, not just a line somewhere nearby. We haven't put a huge amount of effort into making sure all the error messages are accurate yet, so there could be some tweaking still needed, although the majority of messages I've seen have been spot-on. Error messages now contain a column number in addition to the line number, eg. read001.hs:25:10: Variable not in scope: `+#' To get the full text span info, use the new option -ferror-spans. eg. read001.hs:25:10-11: Variable not in scope: `+#' I'm not sure whether we should do this by default. Emacs won't understand the new error format, for one thing. In a more elaborate editor setting (eg. Visual Studio), we can arrange to actually highlight the subexpression containing an error. Eventually this information will be used so we can find elements in the abstract syntax corresponding to text locations, for performing high-level editor functions (eg. "tell me the type of this expression I just highlighted"). Performance of the compiler doesn't seem to be adversely affected. Parsing is still quicker than in 6.0.1, for example. Implementation: This was an excrutiatingly painful change to make: both Simon P.J. and myself have been working on it for the last three weeks or so. The basic changes are: - a new datatype SrcSpan, which represents a beginning and end position in a source file. - To reduce the pain as much as possible, we also defined: data Located e = L SrcSpan e - Every datatype in HsSyn has an equivalent Located version. eg. type LHsExpr id = Located (HsExpr id) and pretty much everywhere we used to use HsExpr we now use LHsExpr. Believe me, we thought about this long and hard, and all the other options were worse :-) Additional changes/cleanups we made at the same time: - The abstract syntax for bindings is now less arcane. MonoBinds and HsBinds with their built-in list constructors have gone away, replaced by HsBindGroup and HsBind (see HsSyn/HsBinds.lhs). - The various HsSyn type synonyms have now gone away (eg. RdrNameHsExpr, RenamedHsExpr, and TypecheckedHsExpr are now HsExpr RdrName, HsExpr Name, and HsExpr Id respectively). - Utilities over HsSyn are now collected in a new module HsUtils. More stuff still needs to be moved in here. - MachChar now has a real Char instead of an Int. All GHC versions that can compile GHC now support 32-bit Chars, so this was a simplification.
-
- 06 Nov, 2003 1 commit
-
-
simonpj authored
------------------------------------ Major increment for Template Haskell ------------------------------------ 1. New abstract data type "Name" which appears where String used to be. E.g. data Exp = VarE Name | ... 2. New syntax 'x and ''T, for quoting Names. It's rather like [| x |] and [t| T |] respectively, except that a) it's non-monadic: 'x :: Name b) you get a Name not an Exp or Type 3. reify is an ordinary function reify :: Name -> Q Info New data type Info which tells what TH knows about Name 4. Local variables work properly. So this works now (crashed before): f x = $( [| x |] ) 5. THSyntax is split up into three modules: Language.Haskell.TH TH "clients" import this Language.Haskell.TH.THSyntax data type declarations and internal stuff Language.Haskell.TH.THLib Support library code (all re-exported by TH), including smart constructors and pretty printer 6. Error reporting and recovery are in (not yet well tested) report :: Bool {- True <=> fatal -} -> String -> Q () recover :: Q a -> Q a -> Q a 7. Can find current module currentModule :: Q String Much other cleaning up, needless to say.
-
- 31 Oct, 2003 1 commit
-
-
simonpj authored
Wibble to TH -> HsSyn conversion
-
- 30 Oct, 2003 2 commits
- 23 Oct, 2003 1 commit
-
-
simonpj authored
Another HsForAllTy wibble
-
- 21 Oct, 2003 1 commit
-
-
simonpj authored
1. A tiresome change to HsType, to keep a record of whether or not the HsForAll was originally explicitly-quantified. This is solely so that the type checker can print out messages that show the source code the programmer wrote. Tiresome but easy. 2. Improve reporting of kind errors.
-
- 09 Oct, 2003 1 commit
-
-
simonpj authored
------------------------- GHC heart/lung transplant ------------------------- This major commit changes the way that GHC deals with importing types and functions defined in other modules, during renaming and typechecking. On the way I've changed or cleaned up numerous other things, including many that I probably fail to mention here. Major benefit: GHC should suck in many fewer interface files when compiling (esp with -O). (You can see this with -ddump-rn-stats.) It's also some 1500 lines of code shorter than before. ** So expect bugs! I can do a 3-stage bootstrap, and run ** the test suite, but you may be doing stuff I havn't tested. ** Don't update if you are relying on a working HEAD. In particular, (a) External Core and (b) GHCi are very little tested. But please, please DO test this version! ------------------------ Big things ------------------------ Interface files, version control, and importing declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * There is a totally new data type for stuff that lives in interface files: Original names IfaceType.IfaceExtName Types IfaceType.IfaceType Declarations (type,class,id) IfaceSyn.IfaceDecl Unfoldings IfaceSyn.IfaceExpr (Previously we used HsSyn for type/class decls, and UfExpr for unfoldings.) The new data types are in iface/IfaceType and iface/IfaceSyn. They are all instances of Binary, so they can be written into interface files. Previous engronkulation concering the binary instance of RdrName has gone away -- RdrName is not an instance of Binary any more. Nor does Binary.lhs need to know about the ``current module'' which it used to, which made it specialised to GHC. A good feature of this is that the type checker for source code doesn't need to worry about the possibility that we might be typechecking interface file stuff. Nor does it need to do renaming; we can typecheck direct from IfaceSyn, saving a whole pass (module TcIface) * Stuff from interface files is sucked in *lazily*, rather than being eagerly sucked in by the renamer. Instead, we use unsafeInterleaveIO to capture a thunk for the unfolding of an imported function (say). If that unfolding is every pulled on, TcIface will scramble over the unfolding, which may in turn pull in the interface files of things mentioned in the unfolding. The External Package State is held in a mutable variable so that it can be side-effected by this lazy-sucking-in process (which may happen way later, e.g. when the simplifier runs). In effect, the EPS is a kind of lazy memo table, filled in as we suck things in. Or you could think of it as a global symbol table, populated on demand. * This lazy sucking is very cool, but it can lead to truly awful bugs. The intent is that updates to the symbol table happen atomically, but very bad things happen if you read the variable for the table, and then force a thunk which updates the table. Updates can get lost that way. I regret this subtlety. One example of the way it showed up is that the top level of TidyPgm (which updates the global name cache) to be much more disciplined about those updates, since TidyPgm may itself force thunks which allocate new names. * Version numbering in interface files has changed completely, fixing one major bug with ghc --make. Previously, the version of A.f changed only if A.f's type and unfolding was textually different. That missed changes to things that A.f's unfolding mentions; which was fixed by eagerly sucking in all of those things, and listing them in the module's usage list. But that didn't work with --make, because they might have been already sucked in. Now, A.f's version changes if anything reachable from A.f (via interface files) changes. A module with unchanged source code needs recompiling only if the versions of any of its free variables changes. [This isn't quite right for dictionary functions and rules, which aren't mentioned explicitly in the source. There are extensive comments in module MkIface, where all version-handling stuff is done.] * We don't need equality on HsDecls any more (because they aren't used in interface files). Instead we have a specialised equality for IfaceSyn (eqIfDecl etc), which uses IfaceEq instead of Bool as its result type. See notes in IfaceSyn. * The horrid bit of the renamer that tried to predict what instance decls would be needed has gone entirely. Instead, the type checker simply sucks in whatever instance decls it needs, when it needs them. Easy! Similarly, no need for 'implicitModuleFVs' and 'implicitTemplateHaskellFVs' etc. Hooray! Types and type checking ~~~~~~~~~~~~~~~~~~~~~~~ * Kind-checking of types is far far tidier (new module TcHsTypes replaces the badly-named TcMonoType). Strangely, this was one of my original goals, because the kind check for types is the Right Place to do type splicing, but it just didn't fit there before. * There's a new representation for newtypes in TypeRep.lhs. Previously they were represented using "SourceTypes" which was a funny compromise. Now they have their own constructor in the Type datatype. SourceType has turned back into PredType, which is what it used to be. * Instance decl overlap checking done lazily. Consider instance C Int b instance C a Int These were rejected before as overlapping, because when seeking (C Int Int) one couldn't tell which to use. But there's no problem when seeking (C Bool Int); it can only be the second. So instead of checking for overlap when adding a new instance declaration, we check for overlap when looking up an Inst. If we find more than one matching instance, we see if any of the candidates dominates the others (in the sense of being a substitution instance of all the others); and only if not do we report an error. ------------------------ Medium things ------------------------ * The TcRn monad is generalised a bit further. It's now based on utils/IOEnv.lhs, the IO monad with an environment. The desugarer uses the monad too, so that anything it needs can get faulted in nicely. * Reduce the number of wired-in things; in particular Word and Integer are no longer wired in. The latter required HsLit.HsInteger to get a Type argument. The 'derivable type classes' data types (:+:, :*: etc) are not wired in any more either (see stuff about derivable type classes below). * The PersistentComilerState is now held in a mutable variable in the HscEnv. Previously (a) it was passed to and then returned by many top-level functions, which was painful; (b) it was invariably accompanied by the HscEnv. This change tidies up top-level plumbing without changing anything important. * Derivable type classes are treated much more like 'deriving' clauses. Previously, the Ids for the to/from functions lived inside the TyCon, but now the TyCon simply records their existence (with a simple boolean). Anyone who wants to use them must look them up in the environment. This in turn makes it easy to generate the to/from functions (done in types/Generics) using HsSyn (like TcGenDeriv for ordinary derivings) instead of CoreSyn, which in turn means that (a) we don't have to figure out all the type arguments etc; and (b) it'll be type-checked for us. Generally, the task of generating the code has become easier, which is good for Manuel, who wants to make it more sophisticated. * A Name now says what its "parent" is. For example, the parent of a data constructor is its type constructor; the parent of a class op is its class. This relationship corresponds exactly to the Avail data type; there may be other places we can exploit it. (I made the change so that version comparison in interface files would be a bit easier; but in fact it tided up other things here and there (see calls to Name.nameParent). For example, the declaration pool, of declararations read from interface files, but not yet used, is now keyed only by the 'main' name of the declaration, not the subordinate names. * New types OccEnv and OccSet, with the usual operations. OccNames can be efficiently compared, because they have uniques, thanks to the hashing implementation of FastStrings. * The GlobalRdrEnv is now keyed by OccName rather than RdrName. Not only does this halve the size of the env (because we don't need both qualified and unqualified versions in the env), but it's also more efficient because we can use a UniqFM instead of a FiniteMap. Consequential changes to Provenance, which has moved to RdrName. * External Core remains a bit of a hack, as it was before, done with a mixture of HsDecls (so that recursiveness and argument variance is still inferred), and IfaceExprs (for value declarations). It's not thoroughly tested. ------------------------ Minor things ------------------------ * DataCon fields dcWorkId, dcWrapId combined into a single field dcIds, that is explicit about whether the data con is a newtype or not. MkId.mkDataConWorkId and mkDataConWrapId are similarly combined into MkId.mkDataConIds * Choosing the boxing strategy is done for *source* type decls only, and hence is now in TcTyDecls, not DataCon. * WiredIn names are distinguished by their n_sort field, not by their location, which was rather strange * Define Maybes.mapCatMaybes :: (a -> Maybe b) -> [a] -> [b] and use it here and there * Much better pretty-printing of interface files (--show-iface) Many, many other small things. ------------------------ File changes ------------------------ * New iface/ subdirectory * Much of RnEnv has moved to iface/IfaceEnv * MkIface and BinIface have moved from main/ to iface/ * types/Variance has been absorbed into typecheck/TcTyDecls * RnHiFiles and RnIfaces have vanished entirely. Their work is done by iface/LoadIface * hsSyn/HsCore has gone, replaced by iface/IfaceSyn * typecheck/TcIfaceSig has gone, replaced by iface/TcIface * typecheck/TcMonoType has been renamed to typecheck/TcHsType * basicTypes/Var.hi-boot and basicTypes/Generics.hi-boot have gone altogether
-
- 15 Aug, 2003 1 commit
-
-
igloo authored
Add support for splicing in foreign exports.
-
- 24 Jun, 2003 1 commit
-
-
simonpj authored
---------------------------------------------- Add support for Ross Paterson's arrow notation ---------------------------------------------- Ross Paterson's ICFP'01 paper described syntax to support John Hughes's "arrows", rather as do-notation supports monads. Except that do-notation is relatively modest -- you can write monads by hand without much trouble -- whereas arrow-notation is more-or-less essential for writing arrow programs. It desugars to a massive pile of tuple construction and selection! For some time, Ross has had a pre-processor for arrow notation, but the resulting type error messages (reported in terms of the desugared code) are impenetrable. This commit integrates the syntax into GHC. The type error messages almost certainly still require tuning, but they should be better than with the pre-processor. Main syntactic changes (enabled with -farrows) exp ::= ... | proc pat -> cmd cmd ::= exp1 -< exp2 | exp1 >- exp2 | exp1 -<< exp2 | exp1 >>- exp2 | \ pat1 .. patn -> cmd | let decls in cmd | if exp then cmd1 else cmd2 | do { cstmt1 .. cstmtn ; cmd } | (| exp |) cmd1 .. cmdn | cmd1 qop cmd2 | case exp of { calts } cstmt :: = let decls | pat <- cmd | rec { cstmt1 .. cstmtn } | cmd New keywords and symbols: proc rec -< >- -<< >>- (| |) The do-notation in cmds was not described in Ross's ICFP'01 paper; instead it's in his chapter in The Fun of Programming (Plagrave 2003). The four arrow-tail forms (-<) etc cover (a) which order the pices come in (-< vs >-), and (b) whether the locally bound variables can be used in the arrow part (-< vs -<<) . In previous presentations, the higher-order-ness (b) was inferred, but it makes a big difference to the typing required so it seems more consistent to be explicit. The 'rec' form is also available in do-notation: * you can use 'rec' in an ordinary do, with the obvious meaning * using 'mdo' just says "infer the minimal recs" Still to do ~~~~~~~~~~~ Top priority is the user manual. The implementation still lacks an implementation of the case form of cmd. Implementation notes ~~~~~~~~~~~~~~~~~~~~ Cmds are parsed, and indeed renamed, as expressions. The type checker distinguishes the two.
-
- 08 Jun, 2003 1 commit
-
-
igloo authored
Introduce a ListP for consistency with ListE. Splicing in something with a list pattern now works too. Added various list tests.
-
- 06 Jun, 2003 1 commit
-
-
igloo authored
Template Haskell Renamings as described in http://www.haskell.org/pipermail/template-haskell/2003-May/000110.html
-
- 21 May, 2003 2 commits
-
-
igloo authored
The Great Renaming. I hope I've kept everything in sync - and all the tests pass. Now datatypes follow the data Foo = <a kind of Foo>Foo | <another kind of Foo>Foo convention and the smart constructors can be uniformly created by lowercasing the first letter of the constructor.
-
igloo authored
Added support for newtypes to TH and altered a test for them.
-
- 19 May, 2003 1 commit
-
-
simonpj authored
-------------------------- Minor Template Haskell bug -------------------------- This bug meant that spliced-in class declarations yielded a 'op not in scope', where op was the class operation. Thanks to Andre Pang for spotting this. Some consequential tidying up in parsing too.
-
- 04 May, 2003 1 commit
-
-
igloo authored
Add support for unboxed Ints, Floats and Doubles to Template Haskell.
-
- 25 Apr, 2003 1 commit
-
-
panne authored
Unbreak 2nd stage
-
- 22 Apr, 2003 1 commit
-
-
igloo authored
Order declarations in reifications in order of source line number. The bugs still there but it bites less often now... Also remove the type parameterisation and do some type renaming as discussed on the template-haskell list.
-
- 16 Mar, 2003 1 commit
-
-
igloo authored
Support for contexts on data types and records from Derek Elkins.
-
- 18 Feb, 2003 1 commit
-
-
igloo authored
Support strictness annotations on data declarations and support the record and infix constructors. Also tweaked the pretty printer a bit.
-
- 12 Feb, 2003 1 commit
-
-
simonpj authored
------------------------------------- Big upheaval to the way that constructors are named ------------------------------------- This commit enshrines the new story for constructor names. We could never really get External Core to work nicely before, but now it does. The story is laid out in detail in the Commentary ghc/docs/comm/the-beast/data-types.html so I will not repeat it here. [Manuel: the commentary isn't being updated, apparently.] However, the net effect is that in Core and in External Core, contructors look like constructors, and the way things are printed is all consistent. It is a fairly pervasive change (which is why it has been so long postponed), but I hope the question is now finally closed. All the libraries compile etc, and I've run many tests, but doubtless there will be some dark corners.
-
- 06 Feb, 2003 2 commits
-
-
simonpj authored
Deal with TForall in cvtType
-
simonpj authored
------------------------------------- Fix parsing of floating-point constants in External Core ------------------------------------- This fix accidentally made it into the previous (unrelated) commit, so it's really the *previous* change to LexCore you should look at. The fix updates LexCore so that it can parse literals in scientific notation (e.g. 4.3e-3)
-
- 18 Dec, 2002 2 commits
- 11 Dec, 2002 2 commits