- 11 Aug, 2005 1 commit
-
-
simonpj authored
Further wibbles to moving dependency analysis back to renamer; fixes ghci failures
-
- 25 Jul, 2005 2 commits
-
-
simonpj authored
Wibbles to the big HsBinds reorg
-
simonpj authored
MERGE TO STABLE if poss Make the "root main" Id :Main.main into an *implicit* Id, whose parent is Main.main. What that means is that the "root main" Id won't be emitted into the interface file. Which has not been causing a problem in practice but is clearly wrong -- there were two 'main's in the interface file.
-
- 19 Jul, 2005 1 commit
-
-
simonpj authored
WARNING: this is a big commit. You might want to wait a few days before updating, in case I've broken something. However, if any of the changes are what you wanted, please check it out and test! This commit does three main things: 1. A re-organisation of the way that GHC handles bindings in HsSyn. This has been a bit of a mess for quite a while. The key new types are -- Bindings for a let or where clause data HsLocalBinds id = HsValBinds (HsValBinds id) | HsIPBinds (HsIPBinds id) | EmptyLocalBinds -- Value bindings (not implicit parameters) data HsValBinds id = ValBindsIn -- Before typechecking (LHsBinds id) [LSig id] -- Not dependency analysed -- Recursive by default | ValBindsOut -- After typechecking [(RecFlag, LHsBinds id)]-- Dependency analysed 2. Implement Mark Jones's idea of increasing polymoprhism by using type signatures to cut the strongly-connected components of a recursive group. As a consequence, GHC no longer insists on the contexts of the type signatures of a recursive group being identical. This drove a significant change: the renamer no longer does dependency analysis. Instead, it attaches a free-variable set to each binding, so that the type checker can do the dep anal. Reason: the typechecker needs to do *two* analyses: one to find the true mutually-recursive groups (which we need so we can build the right CoreSyn) one to find the groups in which to typecheck, taking account of type signatures 3. Implement non-ground SPECIALISE pragmas, as promised, and as requested by Remi and Ross. Certainly, this should fix the current problem with GHC, namely that if you have g :: Eq a => a -> b -> b then you can now specialise thus SPECIALISE g :: Int -> b -> b (This didn't use to work.) However, it goes further than that. For example: f :: (Eq a, Ix b) => a -> b -> b then you can make a partial specialisation SPECIALISE f :: (Eq a) => a -> Int -> Int In principle, you can specialise f to *any* type that is "less polymorphic" (in the sense of subsumption) than f's actual type. Such as SPECIALISE f :: Eq a => [a] -> Int -> Int But I haven't tested that. I implemented this by doing the specialisation in the typechecker and desugarer, rather than leaving around the strange SpecPragmaIds, for the specialiser to find. Indeed, SpecPragmaIds have vanished altogether (hooray). Pragmas in general are handled more tidily. There's a new data type HsBinds.Prag, which lives in an AbsBinds, and carries pragma info from the typechecker to the desugarer. Smaller things - The loop in the renamer goes via RnExpr, instead of RnSource. (That makes it more like the type checker.) - I fixed the thing that was causing 'check_tc' warnings to be emitted.
-
- 21 Jun, 2005 1 commit
-
-
simonmar authored
Relax the restrictions on conflicting packages. This should address many of the traps that people have been falling into with the current package story. Now, a local module can shadow a module in an exposed package, as long as the package is not otherwise required by the program. GHC checks for conflicts when it knows the dependencies of the module being compiled. Also, we now check for module conflicts in exposed packages only when importing a module: if an import can be satisfied from multiple packages, that's an error. It's not possible to prevent GHC from starting by installing packages now (unless you install another base package). It seems to be possible to confuse GHCi by having a local module shadowing a package module that goes away and comes back again. I think it's nearly right, but strange happenings have been observed. I'll try to merge this into the STABLE branch.
-
- 15 Jun, 2005 1 commit
-
-
simonmar authored
Re-implement GHCi's :info and :browse commands in terms of TyThings rather than IfaceSyn. The GHC API now exposes its internal types for Haskell entities: TyCons, Classes, DataCons, Ids and Instances (collectively known as TyThings), so we can inspect these directly to pretty-print information about an entity. Previously the internal representations were converted to IfaceSyn for passing to InteractiveUI, but we can now remove that code. Some of the new code comes via Visual Haskell, but I've changed it around a lot to fix various dark corners and properly print things like GADTs. The pretty-printing interfaces for TyThings are exposed by a new module PprTyThing, which is implemented purely in terms of the GHC API (and is probably a good source of sample code). Visual Haskell should be able to use the functions exported by this module directly. Lots of new goodies are exported by the GHC module, mainly for inspecting TyThings.
-
- 31 May, 2005 1 commit
-
-
simonmar authored
Fix some reporting of errors in the GHC API: errors during the downsweep were thrown as exceptions; now they're reported via the (Messages->IO ()) callback in the same way as other errors. getModuleInfo no longer prints anything on stdout. It does ignore error messages and return Nothing, however - we should fix this and return the error messages at some point. The ErrMsg type can now be thrown as an exception. This can be a convenient alternative if collecting multiple error messages isn't required. We do this in the downsweep now.
-
- 24 May, 2005 1 commit
-
-
simonpj authored
Yet another wibble to the GHCi top-level interaction story; avoid dup error messages
-
- 23 May, 2005 2 commits
- 20 May, 2005 3 commits
-
-
simonpj authored
Further wibble to preceding GHCi commit
-
simonpj authored
Wibble to preceding GHCi commit
-
simonpj authored
Improve the GHCi interaction Merge to STABLE? This fix addresses Sourceforge #1156554 "GHCi: No instance for (Show (IO ()))", and simultaneously improves the top-level interaction in two other ways: - Only one error can show up (previously there could be two) - If an I/O action gives a Showable result, the result is printed (provided it isn't ()). So prompt> return 4 prints 4, rather than nothing - For command-line 'let' and 'x<-e' forms, if exactly one variable is bound, we print its value if it is Showable and not () prompt> let x = 4 4 prompt> x <- return 5 5
-
- 19 May, 2005 1 commit
-
-
simonpj authored
Make sure the default methods are in scope in a Template Haskell splice Merge to STABLE This was just a typo really; in TcRnDriver.tcTopSrcDecls there were two tcl_envs, but one had a different name so we got the less up-to-date one. Fixes SourceForge item #1194808 TH_spliceInst tests it.
-
- 05 May, 2005 2 commits
- 04 May, 2005 1 commit
-
-
simonmar authored
getModuleInfo now does something reasonable for package modules.
-
- 03 May, 2005 2 commits
-
-
simonpj authored
Improve generation of 'duplicate import' warnings. This involved changing (actually simplifying) the definition of RdrName.ImportSpec. I'm not sure whether this one merits merging or not. Perhaps worth a try.
-
simonpj authored
Fix the test for duplicate local bindings, so that it works with Template Haskell. Pre-TH, all the local bindings came into scope at once, but with TH they come into scope in groups, and we must check for conflict with existing local bindings. MERGE TO STABLE
-
- 02 May, 2005 1 commit
-
-
simonpj authored
In the :i command for ghci, load the interface files for the home module of every in-scope type or class. That way we are sure to see all their instance declarations. MERGE TO STABLE branch
-
- 29 Apr, 2005 2 commits
- 28 Apr, 2005 2 commits
-
-
simonpj authored
Further stage-2 wibbles
-
simonpj authored
This big commit does several things at once (aeroplane hacking) which change the format of interface files. So you'll need to recompile your libraries! 1. The "stupid theta" of a newtype declaration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retain the "stupid theta" in a newtype declaration. For some reason this was being discarded, and putting it back in meant changing TyCon and IfaceSyn slightly. 2. Overlap flags travel with the instance ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Arrange that the ability to support overlap and incoherence is a property of the *instance declaration* rather than the module that imports the instance decl. This allows a library writer to define overlapping instance decls without the library client having to know. The implementation is that in an Instance we store the overlap flag, and preseve that across interface files 3. Nuke the "instnce pool" and "rule pool" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A major tidy-up and simplification of the way that instances and rules are sucked in from interface files. Up till now an instance decl has been held in a "pool" until its "gates" (a set of Names) are in play, when the instance is typechecked and added to the InstEnv in the ExternalPackageState. This is complicated and error-prone; it's easy to suck in too few (and miss an instance) or too many (and thereby be forced to suck in its type constructors, etc). Now, as we load an instance from an interface files, we put it straight in the InstEnv... but the Instance we put in the InstEnv has some Names (the "rough-match" names) that can be used on lookup to say "this Instance can't match". The detailed dfun is only read lazily, and the rough-match thing meansn it is'nt poked on until it has a chance of being needed. This simply continues the successful idea for Ids, whereby they are loaded straightaway into the TypeEnv, but their TyThing is a lazy thunk, not poked on until the thing is looked up. Just the same idea applies to Rules. On the way, I made CoreRule and Instance into full-blown records with lots of info, with the same kind of key status as TyCon or DataCon or Class. And got rid of IdCoreRule altogether. It's all much more solid and uniform, but it meant touching a *lot* of modules. 4. Allow instance decls in hs-boot files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Allowing instance decls in hs-boot files is jolly useful, becuase in a big mutually-recursive bunch of data types, you want to give the instances with the data type declarations. To achieve this * The hs-boot file makes a provisional name for the dict-fun, something like $fx9. * When checking the "mother module", we check that the instance declarations line up (by type) and generate bindings for the boot dfuns, such as $fx9 = $f2 where $f2 is the dfun generated by the mother module * In doing this I decided that it's cleaner to have DFunIds get their final External Name at birth. To do that they need a stable OccName, so I have an integer-valued dfun-name-supply in the TcM monad. That keeps it simple. This feature is hardly tested yet. 5. Tidy up tidying, and Iface file generation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main/TidyPgm now has two entry points: simpleTidyPgm is for hi-boot files, when typechecking only (not yet implemented), and potentially when compiling without -O. It ignores the bindings, and generates a nice small TypeEnv. optTidyPgm is the normal case: compiling with -O. It generates a TypeEnv rich in IdInfo MkIface.mkIface now only generates a ModIface. A separate procedure, MkIface.writeIfaceFile, writes the file out to disk.
-
- 27 Apr, 2005 1 commit
-
-
simonmar authored
Support for returning the renamed syntax from checkModule (untested).
-
- 16 Apr, 2005 1 commit
-
-
simonpj authored
Significant clean-up of the handling of hi-boot files. Previously, when compling A.hs, we loaded A.hi-boot, and it went into the External Package Table. It was strange but it worked. This tidy up stops it going anywhere; it's just read in, and typechecked into a ModDetails. All this was on the way to improving the handling of instances in hs-boot files, something Chris Ryder wanted. I think they work quite sensibly now. If I've got all this right (have not had a chance to fully test it) we can merge it into STABLE.
-
- 08 Apr, 2005 2 commits
- 04 Apr, 2005 2 commits
-
-
simonpj authored
More stage2 wibbles
-
simonpj authored
This commit combines three overlapping things: 1. Make rebindable syntax work for do-notation. The idea here is that, in particular, (>>=) can have a type that has class constraints on its argument types, e.g. (>>=) :: (Foo m, Baz a) => m a -> (a -> m b) -> m b The consequence is that a BindStmt and ExprStmt must have individual evidence attached -- previously it was one batch of evidence for the entire Do Sadly, we can't do this for MDo, because we use bind at a polymorphic type (to tie the knot), so we still use one blob of evidence (now in the HsStmtContext) for MDo. For arrow syntax, the evidence is in the HsCmd. For list comprehensions, it's all built-in anyway. So the evidence on a BindStmt is only used for ordinary do-notation. 2. Tidy up HsSyn. In particular: - Eliminate a few "Out" forms, which we can manage without (e.g. - It ought to be the case that the type checker only decorates the syntax tree, but doesn't change one construct into another. That wasn't true for NPat, LitPat, NPlusKPat, so I've fixed that. - Eliminate ResultStmts from Stmt. They always had to be the last Stmt, which led to awkward pattern matching in some places; and the benefits didn't seem to outweigh the costs. Now each construct that uses [Stmt] has a result expression too (e.g. GRHS). 3. Make 'deriving( Ix )' generate a binding for unsafeIndex, rather than for index. This is loads more efficient. (This item only affects TcGenDeriv, but some of point (2) also affects TcGenDeriv, so it has to be in one commit.)
-
- 31 Mar, 2005 1 commit
-
-
simonmar authored
Tweaks to get the GHC sources through Haddock. Doesn't quite work yet, because Haddock complains about the recursive modules. Haddock needs to understand SOURCE imports (it can probably just ignore them as a first attempt).
-
- 22 Mar, 2005 1 commit
-
-
simonmar authored
A start on the GHC API: Flesh out the GHC module so that it can replace CompManager. Now, the clients that used CompManager consume the GHC API instead (namely Main, DriverMkDepend, and InteractiveUI). Main is significantly cleaner as a result. The interface needs more work: in particular, getInfo returns results in the form of IfaceDecls but we want to use full HsSyn and Id/DataCon/Class across the boundary instead. The interfaces for inspecting loaded modules are not yet implemented.
-
- 18 Mar, 2005 1 commit
-
-
simonmar authored
Flags cleanup. Basically the purpose of this commit is to move more of the compiler's global state into DynFlags, which is moving in the direction we need to go for the GHC API which can have multiple active sessions supported by a single GHC instance. Before: $ grep 'global_var' */*hs | wc -l 78 After: $ grep 'global_var' */*hs | wc -l 27 Well, it's an improvement. Most of what's left won't really affect our ability to host multiple sessions. Lots of static flags have become dynamic flags (yay!). Notably lots of flags that we used to think of as "driver" flags, like -I and -L, are now dynamic. The most notable static flags left behind are the "way" flags, eg. -prof. It would be nice to fix this, but it isn't urgent. On the way, lots of cleanup has happened. Everything related to static and dynamic flags lives in StaticFlags and DynFlags respectively, and they share a common command-line parser library in CmdLineParser. The flags related to modes (--makde, --interactive etc.) are now private to the front end: in fact private to Main itself, for now.
-
- 17 Mar, 2005 1 commit
-
-
simonpj authored
Buglet in compiling hs-boot files We should make GlobalIds not LocalIds Merge to STABLE
-
- 08 Mar, 2005 1 commit
-
-
simonpj authored
Print full instances in ghci; merge
-
- 07 Feb, 2005 1 commit
-
-
simonpj authored
Missing commit from the module A export list commit
-
- 28 Jan, 2005 1 commit
-
-
simonpj authored
Arrange that when seeking instance decls in GHCi, in response to a :info command, we only print ones whose types are in scope unqualified. This eliminates an alarmingly long list when simply typing ':info Show', say. On the way, I reorganised a bit. GHCi printing happens by converting a TyThing to an IfaceDecl, and printing that. I now arrange to generate unqualifed IfaceExtNames directly during this conversion, based on what is in scope. Previously it was done during the pretty-printing part via the UserStyle. But this is nicer.
-
- 27 Jan, 2005 2 commits
-
-
simonpj authored
Make sure that the interactive context can see home-package instances; I forgot to do this when making tcRnModule find the appropriate intances (TcRnDriver rev 1.91) This was causing SourceForge [ghc-Bugs-1106171].
-
simonpj authored
-------------------------------------------- Replace hi-boot files with hs-boot files -------------------------------------------- This major commit completely re-organises the way that recursive modules are dealt with. * It should have NO EFFECT if you do not use recursive modules * It is a BREAKING CHANGE if you do ====== Warning: .hi-file format has changed, so if you are ====== updating into an existing HEAD build, you'll ====== need to make clean and re-make The details: [documentation still to be done] * Recursive loops are now broken with Foo.hs-boot (or Foo.lhs-boot), not Foo.hi-boot * An hs-boot files is a proper source file. It is compiled just like a regular Haskell source file: ghc Foo.hs generates Foo.hi, Foo.o ghc Foo.hs-boot generates Foo.hi-boot, Foo.o-boot * hs-boot files are precisely a subset of Haskell. In particular: - they have the same import, export, and scoping rules - errors (such as kind errors) in hs-boot files are checked You do *not* need to mention the "original" name of something in an hs-boot file, any more than you do in any other Haskell module. * The Foo.hi-boot file generated by compiling Foo.hs-boot is a machine- generated interface file, in precisely the same format as Foo.hi * When compiling Foo.hs, its exports are checked for compatibility with Foo.hi-boot (previously generated by compiling Foo.hs-boot) * The dependency analyser (ghc -M) knows about Foo.hs-boot files, and generates appropriate dependencies. For regular source files it generates Foo.o : Foo.hs Foo.o : Baz.hi -- Foo.hs imports Baz Foo.o : Bog.hi-boot -- Foo.hs source-imports Bog For a hs-boot file it generates similar dependencies Bog.o-boot : Bog.hs-boot Bog.o-boot : Nib.hi -- Bog.hs-boto imports Nib * ghc -M is also enhanced to use the compilation manager dependency chasing, so that ghc -M Main will usually do the job. No need to enumerate all the source files. * The -c flag is no longer a "compiler mode". It simply means "omit the link step", and synonymous with -no-link.
-
- 21 Jan, 2005 1 commit
-
-
simonmar authored
Don't try to run finalizers at program exit. This turned out to be hard if not impossible to do in general, so now we don't attempt it at all. The Main.main wrapper, previously called runIO and now called runMainIO, flushes stdout and stderr before exiting. This should catch most cases where programs rely on Handles being flushed at program exit, but note that now if you simply drop a Handle in your program, there's no guarantee it'll be flushed on exit. If the punters complain enough, I suppose we could implement a global Handle table and flush them all at exit... I'd rather not do this if possible, though. Better to teach people to close their Handles properly.
-