summaryrefslogtreecommitdiff
path: root/ghc/compiler/rename/RnMonad.lhs
Commit message (Collapse)AuthorAgeFilesLines
* [project @ 2002-09-13 15:02:25 by simonpj]simonpj2002-09-131-760/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------------------------------- Make Template Haskell into the HEAD -------------------------------------- This massive commit transfers to the HEAD all the stuff that Simon and Tim have been doing on Template Haskell. The meta-haskell-branch is no more! WARNING: make sure that you * Update your links if you are using link trees. Some modules have been added, some have gone away. * Do 'make clean' in all library trees. The interface file format has changed, and you can get strange panics (sadly) if GHC tries to read old interface files: e.g. ghc-5.05: panic! (the `impossible' happened, GHC version 5.05): Binary.get(TyClDecl): ForeignType * You need to recompile the rts too; Linker.c has changed However the libraries are almost unaltered; just a tiny change in Base, and to the exports in Prelude. NOTE: so far as TH itself is concerned, expression splices work fine, but declaration splices are not complete. --------------- The main change --------------- The main structural change: renaming and typechecking have to be interleaved, because we can't rename stuff after a declaration splice until after we've typechecked the stuff before (and the splice itself). * Combine the renamer and typecheker monads into one (TcRnMonad, TcRnTypes) These two replace TcMonad and RnMonad * Give them a single 'driver' (TcRnDriver). This driver replaces TcModule.lhs and Rename.lhs * The haskell-src library package has a module Language/Haskell/THSyntax which defines the Haskell data type seen by the TH programmer. * New modules: hsSyn/Convert.hs converts THSyntax -> HsSyn deSugar/DsMeta.hs converts HsSyn -> THSyntax * New module typecheck/TcSplice type-checks Template Haskell splices. ------------- Linking stuff ------------- * ByteCodeLink has been split into ByteCodeLink (which links) ByteCodeAsm (which assembles) * New module ghci/ObjLink is the object-code linker. * compMan/CmLink is removed entirely (was out of place) Ditto CmTypes (which was tiny) * Linker.c initialises the linker when it is first used (no need to call initLinker any more). Template Haskell makes it harder to know when and whether to initialise the linker. ------------------------------------- Gathering the LIE in the type checker ------------------------------------- * Instead of explicitly gathering constraints in the LIE tcExpr :: RenamedExpr -> TcM (TypecheckedExpr, LIE) we now dump the constraints into a mutable varabiable carried by the monad, so we get tcExpr :: RenamedExpr -> TcM TypecheckedExpr Much less clutter in the code, and more efficient too. (Originally suggested by Mark Shields.) ----------------- Remove "SysNames" ----------------- Because the renamer and the type checker were entirely separate, we had to carry some rather tiresome implicit binders (or "SysNames") along inside some of the HsDecl data structures. They were both tiresome and fragile. Now that the typechecker and renamer are more intimately coupled, we can eliminate SysNames (well, mostly... default methods still carry something similar). ------------- Clean up HsPat ------------- One big clean up is this: instead of having two HsPat types (InPat and OutPat), they are now combined into one. This is more consistent with the way that HsExpr etc is handled; there are some 'Out' constructors for the type checker output. So: HsPat.InPat --> HsPat.Pat HsPat.OutPat --> HsPat.Pat No 'pat' type parameter in HsExpr, HsBinds, etc Constructor patterns are nicer now: they use HsPat.HsConDetails for the three cases of constructor patterns: prefix, infix, and record-bindings The *same* data type HsConDetails is used in the type declaration of the data type (HsDecls.TyData) Lots of associated clean-up operations here and there. Less code. Everything is wonderful.
* [project @ 2002-08-29 15:44:11 by simonmar]simonmar2002-08-291-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Housekeeping: - The main goal is to remove dependencies on hslibs for a bootstrapped compiler, leaving only a requirement that the packages base, haskell98 and readline are built in stage 1 in order to bootstrap. We're almost there: Posix is still required for signal handling, but all other dependencies on hslibs are now gone. Uses of Addr and ByteArray/MutableByteArray array are all gone from the compiler. PrimPacked defines the Ptr type for GHC 4.08 (which didn't have it), and it defines simple BA and MBA types to replace uses of ByteArray and MutableByteArray respectively. - Clean up import lists. HsVersions.h now defines macros for some modules which have moved between GHC versions. eg. one now imports 'GLAEXTS' to get at unboxed types and primops in the compiler. Many import lists have been sorted as per the recommendations in the new style guidelines in the commentary. I've built the compiler with GHC 4.08.2, 5.00.2, 5.02.3, 5.04 and itself, and everything still works here. Doubtless I've got something wrong, though.
* [project @ 2002-05-27 15:28:07 by simonpj]simonpj2002-05-271-18/+4
| | | | | | | | | | | | | | | | | Allow infix type constructors This commit adds infix type constructors (but not yet class constructors). The documentation describes what should be the case. Lots of tiresome changes, but nothing exciting. Allows infix type constructors everwhere a type can occur, and in a data or type synonym decl. E.g. data a :*: b = .... You can give fixity decls for type constructors, but the fixity decl applies both to the tycon and the corresponding data con.
* [project @ 2002-03-14 15:27:15 by simonpj]simonpj2002-03-141-1/+1
| | | | | | | | | | | | | | | | | | | ------------------------ Change GlobalName --> ExternalName LocalName -> InternalName ------------------------ For a long time there's been terminological confusion between GlobalName vs LocalName (property of a Name) GlobalId vs LocalId (property of an Id) I've now changed the terminology for Name to be ExternalName vs InternalName I've also added quite a bit of documentation in the Commentary.
* [project @ 2002-03-06 14:47:17 by simonmar]simonmar2002-03-061-5/+9
| | | | Include the fixity declaration for 'seq' in the GHC.Prim interface.
* [project @ 2002-03-05 14:18:53 by simonmar]simonmar2002-03-051-13/+36
| | | | | | | | | | | | | Generate the contents of the GHC.Prim interface file automatically from the list of available PrimOps and various other wired-in things. Two main benefits from this: - There's one fewer places to edit when adding a new primop. - It's one less reason to need the interface file parser, and now we no longer need the (short-lived) --compile-iface option so I've removed it.
* [project @ 2002-03-04 17:01:26 by simonmar]simonmar2002-03-041-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Binary Interface Files - stage 1 -------------------------------- This commit changes the default interface file format from text to binary, in order to improve compilation performace. To view an interface file, use 'ghc --show-iface Foo.hi'. utils/Binary.hs is the basic Binary I/O library, based on the nhc98 binary I/O library but much stripped-down and working in terms of bytes rather than bits, and with some special features for GHC: it remembers which Module is being emitted to avoid dumping too many qualified names, and it keeps track of a "dictionary" of FastStrings so that we don't dump the same FastString more than once into the binary file. I'll make a generic version of this for the libraries at some point. main/BinIface.hs contains most of the Binary instances. Some instances are in the same module as the data type (RdrName, Name, OccName in particular). Most instances were generated using a modified version of DrIFT, which I'll commit later. However, editing them by hand isn't hard (certainly easier than modifying ParseIface.y). The first thing in a binary interface is the interface version, so nice error messages will be generated if the binary format changes and you still have old interfaces lying around. The version also now includes the "way" as an extra sanity check. Other changes ------------- I don't like the way FastStrings contain both hashed strings (with O(1) comparison) and literal C strings (with O(n) comparison). So as a first step to separating these I made serveral "literal" type strings into hashed strings. SLIT() still generates a literal, and now FSLIT() generates a hashed string. With DEBUG on, you'll get a warning if you try to compare any SLIT()s with anything, and the compiler will fall over if you try to dump any literal C strings into an interface file (usually indicating a use of SLIT() which should be FSLIT()). mkSysLocal no longer re-encodes its FastString argument each time it is called. I also fixed the -pgm options so that the argument can now optionally be separted from the option. Bugfix: PrelNames declared Names for several comparison primops, eg. eqCharName, eqIntName etc. but these had different uniques from the real primop names. I've moved these to PrimOps and defined them using mkPrimOpIdName instead, and deleted some for which we don't have real primops (Manuel: please check that things still work for you after this change).
* [project @ 2002-02-05 15:02:23 by simonpj]simonpj2002-02-051-1/+1
| | | | Imports only
* [project @ 2002-01-30 16:37:14 by simonmar]simonmar2002-01-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | Simplify the package story inside the compiler. The new story is this: The Finder no longer determines a module's package based on its filesystem location. The filesystem location indicates only whether a given module is in the current package or not (i.e. found along the -i path ==> current package, found along the package path ==> other package). Hence a Module no longer contains a package name. Instead it just contains PackageInfo, which is either ThisPackage or AnotherPackage. The compiler uses this information for generating cross-DLL calls and omitting certain version information from .hi files. The interface still contains the package name. This isn't used for anything right now, but in the future (when we have hierarchical libraries) we might use it to automatically determine which packages a binary should be linked against. When building a package, you should still use -package-name, but it won't be fatal if you don't. The warning/error about package name mismatches has gone away.
* [project @ 2001-12-07 17:33:26 by simonpj]simonpj2001-12-071-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | ---------------------------- More jiggling in the renamer ---------------------------- I was a little hasty before. (Thanks Sigbjorn for finding this.) This commit tidies up the handling of AvailEnvs. Principally: * filterImports now deals completely with hiding (before it handed off part of the job to mkGlobalRdrEnv) * The AvailEnv in an ExportAvails does not have class ops and data constructors in its domain. This makes plusExportAvails more efficient, but the main thing is that it collects things up right. (Previously, if we had import M( C ) import M( op ) then we got an AvailEnv which had C |-> AvailTC C [C] (no 'op'). * In Rename, we do need a "filled-out" version of the overall AvailEnv, full_avail_env, which we construct on the spot in 'rename'.
* [project @ 2001-12-06 10:45:42 by simonpj]simonpj2001-12-061-8/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------------------- Fix the instance-decl wart -------------------------- This commit implements the (proposed) H98 rule for resolving the class-method name in an instance decl. module M( C( op1, op2 ) ) where -- NB: op3 not exported class C a where op1, op2, op3 :: a -> a module N where import qualified M as P( C ) import qualified M as Q hiding( op2 ) instance P.C Int where op1 x = x -- op2, op3 both illegal here The point is that a) only methods that can be named are legal in the instance decl (so op2, op3 are not legal) b) but it doesn't matter *how* they can be named (in this case Q.op1 is in scope, though the class is called P.C) The AvailEnv carries the information about what's in scope, so we now have to carry it around in the monad, so that instance decl bindings can see it. Quite simple really. Same deal for export lists. E.g. module N( P.C( op1 ) ) where import qualified M as P( C ) import qualified M as Q hiding( op2 ) Actually this is what GHC has always implemented!
* [project @ 2001-08-21 14:35:37 by simonmar]simonmar2001-08-211-0/+6
| | | | Make local bindings work on the GHCi command line again.
* [project @ 2001-08-15 14:40:24 by simonmar]simonmar2001-08-151-0/+15
| | | | Implement the :info command for GHCi.
* [project @ 2001-05-28 13:57:19 by simonmar]simonmar2001-05-281-0/+3
| | | | | | | | | | | | | When we auto-load a module because the user typed a qualified name at the prompt, we better not auto-load a home interface (because we won't have the code to go with it). So, introduce a new constructor in the WhereFrom datatype, namely ImportByCmdLine for these auto-imports, and make findAndReadIface fail if it tries to load a home interface by this route. ToDo: GHCi should *never* demand-load a home interface under any circumstances, but we don't have an ASSERT for this yet.
* [project @ 2001-04-30 10:51:18 by simonpj]simonpj2001-04-301-6/+7
| | | | | | | | | | | | ----------------------------- Better filtering for warnings ----------------------------- * Add Opt_WarnMisc, to enable warnings not otherwise covered by Opt_Warn* in the renamer * Add RnMonad.ifOptRn :: DynFlag -> RnM d a -> RnM d () and use it many places instead of the clumsy direct code
* [project @ 2001-03-14 15:26:00 by simonpj]simonpj2001-03-141-0/+6
| | | | | | | | | | | | | | | | | | | | ------------------------------------- Import more rules, and fix usage info ------------------------------------- 1. A rule wasn't being slurped in that should have been. Reason: wordToWord32# was in the 'TypeEnv', because it's a primop, so the renamer thought it was already slurped in, which is true. But it forgot to use the TypeEnv as a source of gates when deciding which rules to pull in. Result: a useful rule for the primop wasn't making it in. Thanks to Marcin for isolating this one. 2. RnIfaces.recordTypeEnvSlurp (was recordVSlurp) was blindly adding the name to the iVSlurp set, but the iVSlurp set is supposed to contain only "big" names (tycons, classes, and Ids that aren't data cons, class ops etc). We need to get the big name from the thing. Mildly tiresomely, this means we have to keep the Class inside the TyCon derived from that class. Hence updates to TyCon and Class.
* [project @ 2001-03-12 14:06:46 by simonpj]simonpj2001-03-121-1/+1
| | | | | | | | | | | | | | ---------------- First cut at ILX ---------------- This commit puts the ILX .NET code generator into the head. It's entirely untested, mind you. Some changes to the Module/Package strutures, mainly of a naming variety. In particular: Package ===> PackageConfig
* [project @ 2001-03-08 12:07:38 by simonpj]simonpj2001-03-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------------- A major hygiene pass -------------------- 1. The main change here is to Move what was the "IdFlavour" out of IdInfo, and into the varDetails field of a Var It was a mess before, because the flavour was a permanent attribute of an Id, whereas the rest of the IdInfo was ephemeral. It's all much tidier now. Main places to look: Var.lhs Defn of VarDetails IdInfo.lhs Defn of GlobalIdDetails The main remaining infelicity is that SpecPragmaIds are right down in Var.lhs, which seems unduly built-in for such an ephemeral thing. But that is no worse than before. 2. Tidy up the HscMain story a little. Move mkModDetails from MkIface into CoreTidy (where it belongs more nicely) This was partly forced by (1) above, because I didn't want to make DictFun Ids into a separate kind of Id (which is how it was before). Not having them separate means we have to keep a list of them right through, rather than pull them out of the bindings at the end. 3. Add NameEnv as a separate module (to join NameSet). 4. Remove unnecessary {-# SOURCE #-} imports from FieldLabel.
* [project @ 2001-02-26 15:06:57 by simonmar]simonmar2001-02-261-6/+5
| | | | | | | | | | | | | | | | | Implement do-style bindings on the GHCi command line. The syntax for a command-line is exactly that of a do statement, with the following meanings: - `pat <- expr' performs expr, and binds each of the variables in pat. - `let pat = expr; ...' binds each of the variables in pat, doesn't do any evaluation - `expr' behaves as `it <- expr' if expr is IO-typed, or `let it = expr' followed by `print it' otherwise.
* [project @ 2001-01-18 12:54:16 by simonmar]simonmar2001-01-181-2/+6
| | | | | | | | | Make the GHCi command line behave as if an "import qualified M" was in force for all M. The renamer now has a new "mode": CmdLineMode, which changes the lookup machinery to turn a qualified lookup into an original name lookup if the qualified name isn't otherwise in scope.
* [project @ 2000-12-20 10:38:18 by simonmar]simonmar2000-12-201-17/+15
| | | | Simon's renamer fixes from yesterday.
* [project @ 2000-12-18 14:19:35 by simonpj]simonpj2000-12-181-2/+2
| | | | A module's dependencies in its .hi file should not include itself!
* [project @ 2000-12-08 12:32:15 by simonpj]simonpj2000-12-081-7/+7
| | | | Some renaming in HscTypes
* [project @ 2000-12-07 08:22:53 by simonpj]simonpj2000-12-071-21/+13
| | | | Tidy up the Persistent Renamer State structure a little
* [project @ 2000-11-15 14:37:08 by simonpj]simonpj2000-11-151-41/+50
| | | | | | | | | | | | | The main thing in this commit is to change StgAlts so that it carries a TyCon, and not a Type. Furthermore, the TyCon is derived from the alternatives, so it should have its constructors etc, even if there's a module loop involved, so that some versions of the TyCon don't have the constructors visible. There's a comment in StgSyn.lhs, with the type decl for StgAlts Also: a start on hscExpr in HscMain.
* [project @ 2000-11-14 10:46:39 by simonpj]simonpj2000-11-141-1/+1
| | | | Compiles now
* [project @ 2000-11-10 15:12:50 by simonpj]simonpj2000-11-101-10/+12
| | | | | | | | | | | | | | 1. Outputable.PprStyle now carries a bit more information In particular, the printing style tells whether to print a name in unqualified form. This used to be embedded in a Name, but since Names now outlive a single compilation unit, that's no longer appropriate. So now the print-unqualified predicate is passed in the printing style, not embedded in the Name. 2. I tidied up HscMain a little. Many of the showPass messages have migraged into the repective pass drivers
* [project @ 2000-11-09 08:18:11 by simonpj]simonpj2000-11-091-4/+3
| | | | Make data constructors visible in unfoldings
* [project @ 2000-11-08 14:52:06 by simonpj]simonpj2000-11-081-3/+7
| | | | Compiles most of the Prelude; versioning still not good
* [project @ 2000-11-07 13:12:21 by simonpj]simonpj2000-11-071-0/+5
| | | | More small changes
* [project @ 2000-11-03 17:10:57 by simonpj]simonpj2000-11-031-16/+11
| | | | More renamer... not in a working state I fear
* [project @ 2000-10-31 12:07:43 by simonpj]simonpj2000-10-311-3/+2
| | | | Improve MkIface; get ready for NameEnv.lhs
* [project @ 2000-10-31 08:08:38 by simonpj]simonpj2000-10-311-6/+10
| | | | More tidying up; esp of isLocallyDefined
* [project @ 2000-10-30 18:13:15 by sewardj]sewardj2000-10-301-0/+6
| | | | | Move readIface from RnM to IO, and commensurate changes. Also, add a field to ModuleLocation to hold preprocessed source locations.
* [project @ 2000-10-30 17:18:26 by simonpj]simonpj2000-10-301-13/+18
| | | | Renamer tidying up
* [project @ 2000-10-27 11:48:54 by sewardj]sewardj2000-10-271-10/+4
| | | | | Track changes to the finder (now is a global variable and not passed around). Also some fixes to flag handling.
* [project @ 2000-10-25 12:56:20 by simonpj]simonpj2000-10-251-1/+1
| | | | Tons of stuff for the mornings work
* [project @ 2000-10-24 15:55:35 by simonpj]simonpj2000-10-241-1/+1
| | | | More renamer
* [project @ 2000-10-24 10:36:08 by simonpj]simonpj2000-10-241-37/+29
| | | | Wibbles
* [project @ 2000-10-24 10:12:16 by sewardj]sewardj2000-10-241-5/+6
| | | | Make the back-end world compile.
* [project @ 2000-10-24 07:35:00 by simonpj]simonpj2000-10-241-4/+8
| | | | Mainly MkIface
* [project @ 2000-10-23 16:39:11 by simonpj]simonpj2000-10-231-7/+8
| | | | More renamer stuff
* [project @ 2000-10-23 11:50:40 by sewardj]sewardj2000-10-231-4/+5
| | | | Small cleanups.
* [project @ 2000-10-23 09:03:26 by simonpj]simonpj2000-10-231-19/+45
| | | | Mainly renamer
* [project @ 2000-10-20 15:38:42 by sewardj]sewardj2000-10-201-16/+22
| | | | Latest hacks.
* [project @ 2000-10-19 15:00:16 by sewardj]sewardj2000-10-191-0/+4
| | | | Stagger dazedly towards getting the renamer to compile.
* [project @ 2000-10-17 14:40:26 by sewardj]sewardj2000-10-171-15/+20
| | | | Make RnEnv compile.
* [project @ 2000-10-17 13:22:10 by simonmar]simonmar2000-10-171-5/+5
| | | | | | | Flags hacking: - `dopt_GlasgowExts' is now written `dopt Opt_GlasgowExts' - convert all the warning options into DynFlags
* [project @ 2000-10-16 15:35:01 by simonmar]simonmar2000-10-161-1/+1
| | | | CmFind ==> Finder
* [project @ 2000-10-16 13:29:13 by sewardj]sewardj2000-10-161-11/+14
| | | | make HscTypes and RnMonad compilable