| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| |
|
|
| |
More stage2 wibbles
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.)
|
| |
|
|
|
|
|
| |
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).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
----------------------------------
Attend to fixity of '->' in types
----------------------------------
Merge to STABLE
Another wibble to the infix-type-constructor story. Actually
this has been a bug for some time: function type constructors
were not being re-associated, because they are not HsOpAppTys.
|
| |
|
|
| |
Fix what looks like a typo in the previous commit
|
| |
|
|
| |
Avoid losing location info for ghci; please merge
|
| |
|
|
| |
Comments
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
------------------------------
Improve unused-import warnings
------------------------------
Merge to STABLE
This commit improves the warning messages for unused imports, in the
case where the 'module A' form is used in an export list.
In doing this, I've realised that the unused-import checking is deficient
in several ways. At least
a) it doesn't recognise that there might be several import statements
for the same module (TcRnTypes.imp_mods has only one entry per
module
b) it doesn't understand about qualified modules at all
c) even more fundamentally, it starts from the used Names,
but if the module mentions (say) aliases M.f and N.f for
the same Name, then two imports might be necessary for it
I'm not going to fix these problems now; this message just records them.
|
| |
|
|
| |
Import trimming
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
--------------------------------------------
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
------------------------
Reorganisation of hi-boot files
------------------------
The main point of this commit is to arrange that in the Compilation
Manager's dependendency graph, hi-boot files are proper nodes. This
is important to make sure that we compile everything in the right
order. It's a step towards hs-boot files.
* The fundamental change is that CompManager.ModSummary has a new
field, ms_boot :: IsBootInterface
I also tided up CompManager a bit. No change to the Basic Plan.
ModSummary is now exported abstractly from CompManager (was concrete)
* Hi-boot files now have import declarations. The idea is they are
compulsory, so that the dependency analyser can find them
* I changed an invariant: the Compilation Manager used to ensure that
hscMain was given a HomePackageTable only for the modules 'below' the
one being compiled. This was really only important for instances and
rules, and it was a bit inconvenient. So I moved the filter to the
compiler itself: see HscTypes.hptInstances and hptRules.
* Module Packages.hs now defines
data PackageIdH
= HomePackage -- The "home" package is the package
-- curently being compiled
| ExtPackage PackageId -- An "external" package is any other package
It was just a Maybe type before, so this makes it a bit clearer.
* I tried to add a bit better location info to the IfM monad, so that
errors in interfaces come with a slightly more helpful error message.
See the if_loc field in TcRnTypes --- and follow-on consequences
* Changed Either to Maybes.MaybeErr in a couple of places (more perspicuous)
|
| |
|
|
|
|
|
|
| |
lookupFixityRn: we should be using loadHomeInterface rather than
loadSrcInterface here, because this is a system-ish import rather than
an explicit user import. In particular, loadSrcInterface will
complain if the module in question is hidden, but this is not what we
want.
|
| |
|
|
| |
Enable scoped type variables only where there is an explicit forall
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
----------------------------------------
Add more scoped type variables
----------------------------------------
Now the top-level forall'd variables of a type signature scope
over the right hand side of that function.
f :: a -> a
f x = ....
The type variable 'a' is in scope in the RHS, and in f's patterns.
It's implied by -fglasgow-exts, but can also be switched off independently
using -fscoped-type-variables (and the -fno variant)
|
| |
|
|
| |
Restore a test; fixes rnfail042
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Sorry for the fact that there are overlapping three commits in here...
1. Make -fno-monomorphism-restriction
and -fno-implicit-prelude reversible, like other flags
2. Fix a wibble in the new ImportAvails story, in RnNames.mkExportAvails
3. Fix a Template Haskell bug that meant that top-level names created
with newName were not made properly unique.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
---------------------
Simplify ImportAvails
---------------------
Every Name has, for some while, contained its "parent";
the type or class inside which it is defined. But the rest
of the renamer wasn't using this information as much as it
could do. In particular, the ImportAvails type was more elaborate
than necessary.
This commit combines these two fields of ImportAvails:
imp_env :: AvailEnv
imp_qual :: ModuleEnv AvailEnv
into one
imp_env :: ModuleEnv NameSet
This is quite a bit simpler. Less redundancy and, I think, less
code.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Further integration with the new package story. GHC now supports
pretty much everything in the package proposal.
- GHC now works in terms of PackageIds (<pkg>-<version>) rather than
just package names. You can still specify package names without
versions on the command line, as long as the name is unambiguous.
- GHC understands hidden/exposed modules in a package, and will refuse
to import a hidden module. Also, the hidden/eposed status of packages
is taken into account.
- I had to remove the old package syntax from ghc-pkg, backwards
compatibility isn't really practical.
- All the package.conf.in files have been rewritten in the new syntax,
and contain a complete list of modules in the package. I've set all
the versions to 1.0 for now - please check your package(s) and fix the
version number & other info appropriately.
- New options:
-hide-package P sets the expose flag on package P to False
-ignore-package P unregisters P for this compilation
For comparison, -package P sets the expose flag on package P
to True, and also causes P to be linked in eagerly.
-package-name is no longer officially supported. Unofficially, it's
a synonym for -ignore-package, which has more or less the same effect
as -package-name used to.
Note that a package may be hidden and yet still be linked into
the program, by virtue of being a dependency of some other package.
To completely remove a package from the compiler's internal database,
use -ignore-package.
The compiler will complain if any two packages in the
transitive closure of exposed packages contain the same
module.
You *must* use -ignore-package P when compiling modules for
package P, if package P (or an older version of P) is already
registered. The compiler will helpfully complain if you don't.
The fptools build system does this.
- Note: the Cabal library won't work yet. It still thinks GHC uses
the old package config syntax.
Internal changes/cleanups:
- The ModuleName type has gone away. Modules are now just (a
newtype of) FastStrings, and don't contain any package information.
All the package-related knowledge is in DynFlags, which is passed
down to where it is needed.
- DynFlags manipulation has been cleaned up somewhat: there are no
global variables holding DynFlags any more, instead the DynFlags
are passed around properly.
- There are a few less global variables in GHC. Lots more are
scheduled for removal.
- -i is now a dynamic flag, as are all the package-related flags (but
using them in {-# OPTIONS #-} is Officially Not Recommended).
- make -j now appears to work under fptools/libraries/. Probably
wouldn't take much to get it working for a whole build.
|
| |
|
|
| |
wibble
|
| |
|
|
| |
Fix a bug in fixity handling for tycons; we were rembering the data-con RdrName, not the tycon one
|
| |
|
|
| |
Refine warning slightly
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
---------------------------------
Fix a bug in usage recording
---------------------------------
As a result of the new stuff on hi-boot-file consistency checking, I
accidentally caused Foo.hi to record a usage line for module Foo, and
this in turn caused rather nasty bad things to happen. In particular,
there were occasional crashes of form
ghc-6.3: panic! (the `impossible' happened, GHC version 6.3.20041017):
forkM Constructor Var.TcTyVar{d r1B9}
At least I think that's why the crash happened.
Anyway, it was certainly a bug, and this commit fixes it. The main
payload of this fix is in Desugar.lhs; the rest is comments and
tidying.
|
| |
|
|
| |
Improve error message
|
| |
|
|
| |
Better reporting of duplicate top-level defns
|
| |
|
|
| |
Improve error locations for binding conflicts
|
| |
|
|
| |
Allow kind signatures in GADT data type declarations
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
------------------------------------
Simplify the treatment of newtypes
Complete hi-boot file consistency checking
------------------------------------
In the representation of types, newtypes used to have a special constructor
all to themselves, very like TyConApp, called NewTcApp. The trouble is
that means we have to *know* when a newtype is a newtype, and in an hi-boot
context we may not -- the data type might be declared as
data T
in the hi-boot file, but as
newtype T = ...
in the source file. In GHCi, which accumulates stuff from multiple compiles,
this makes a difference.
So I've nuked NewTcApp. Newtypes are represented using TyConApps again. This
turned out to reduce the total amount of code, and simplify the Type data type,
which is all to the good.
This commit also fixes a few things in the hi-boot consistency checking
stuff.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
-----------------------------------
Do simple checking on hi-boot files
-----------------------------------
This commit arranges that, when compiling A.hs, we compare
the types we infer with those in A.hi-boot, if the latter
exists. (Or, more accurately, if anything A.hs imports in
turn imports A.hi-boot, directly or indirectly.)
This has been on the to-do list forever.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
------------------------------------
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).
|
| |
|
|
| |
Make error messages consistent
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-------------------------------
Print built-in sytax right
-------------------------------
Built-in syntax, like (:) and [], is not "in scope" via the GlobalRdrEnv
in the usual way. When we print it out, we should also print it in unqualified
form, even though it's not in the environment.
I've finally bitten the (not very big) bullet, and added to Name the information
about whether or not a name is one of these built-in ones. That entailed changing
the calls to mkWiredInName, but those are exactly the places where you have to
decide whether it's built-in or not, which is fine.
Built-in syntax => It's a syntactic form, not "in scope" (e.g. [])
Wired-in thing => The thing (Id, TyCon) is fully known to the compiler,
not read from an interface file.
E.g. Bool, True, Int, Float, and many others
All built-in syntax is for wired-in things.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-------------------------------
Use merge-sort not quicksort
Nuke quicksort altogether
-------------------------------
Quicksort has O(n**2) behaviour worst case, and this occasionally bites.
In particular, when compiling large files consisting only of static data,
we get loads of top-level delarations -- and that led to more than half the
total compile time being spent in the strongly connected component analysis
for the occurrence analyser. Switching to merge sort completely solved the
problem.
I've nuked quicksort altogether to make sure this does not happen again.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-------------------------------
Add instance information to :i
Get rid of the DeclPool
-------------------------------
1. Add instance information to :info command. GHCi now prints out
which instances a type or class belongs to, when you use :i
2. Tidy up printing of unqualified names in user output.
Previously Outputable.PrintUnqualified was
type PrintUnqualified = Name -> Bool
but it's now
type PrintUnqualified = ModuleName -> OccName -> Bool
This turns out to be tidier even for Names, and it's now also usable
when printing IfaceSyn stuff in GHCi, eliminating a grevious hack.
3. On the way to doing this, Simon M had the great idea that we could
get rid of the DeclPool holding pen, which held declarations read from
interface files but not yet type-checked. We do this by eagerly
populating the TypeEnv with thunks what, when poked, do the type
checking. This is just a logical continuation of lazy import
mechanism we've now had for some while.
The InstPool and RulePool still exist, but I plan to get rid of them in
the same way. The new scheme does mean that more rules get sucked in than
before, because previously the TypeEnv was used to mean "this thing was needed"
and hence to control which rules were sucked in. But now the TypeEnv is
populated more eagerly => more rules get sucked in. However this problem
will go away when I get rid of the Inst and Rule pools.
I should have kept these changes separate, but I didn't. Change (1)
affects mainly
TcRnDriver, HscMain, CompMan, InteractiveUI
whereas change (3) is more wide ranging.
|
| |
|
|
| |
Fix problem with :i for (:)
|
| |
|
|
|
|
|
|
| |
-----------------------------------------------
Improve reporting of TH reify out-of-scope errors
-----------------------------------------------
No change to functionality, just better error reports.
|
| |
|
|
| |
Renamed Opt_WarnMisc to Opt_WarnDodgyImports
|
| |
|
|
|
|
|
|
|
|
|
|
| |
-----------------------------------------------
Decent error on re-use of built-in syntax
-----------------------------------------------
Make the renamer complain nicely on stupid stuff like
data T = []
(except in the Prelude, of course!)
|
| |
|
|
|
|
|
|
|
| |
-----------------------------------------------
Improve location info on unused-import warnings
-----------------------------------------------
Improving the location involves plumbing the location of the import a bit
more assiduously -- hence change to imp_mods in TcRnTypes
|
| |
|
|
|
|
| |
In multiple declaration errors, give the location of one of the
declarations as the location of the error message, instead of the
top-level of the file.
|
| |
|
|
| |
White space
|
| |
|
|
| |
Add ASSERT
|
| |
|
|
|
|
| |
The "rebindable-syntax" stuff wasn't dealing with the new location
information correctly. This commit fixes the problem, and thereby
makes mdofail004 work right. Maybe others too.
|
| |
|
|
|
|
|
|
|
| |
Remove the entirely-redundant location from the argument of
constructor HsPredTy,
so that we have
HsPredTy HsType
rather than
HsPredTy LHsType
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Extend the "newtype deriving" feature a little bit more
(at the request of Wolfgang Jeltsch)
Here's the example:
class C a b
instance C [a] Char
newtype T = T Char deriving( C [a] )
Perfectly sensible, and no reason it should not work.
Fixing this required me to generalise the abstract syntax of
a 'deriving' item, hence the non-local effects.
|
| |
|
|
| |
Back out hiding change -- hiding should hide the qualified name too
|
| |
|
|
|
|
|
| |
Fix a long-standing bug, whereby 'hiding' hid the qualified name as
well as the unqualified one.
This bug is not as easy to fix in the 6.2 branch, unfortunately; don't merge.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
---------------------------------------
Record dependency on Template Haskell package
---------------------------------------
An unforseen consequence of making the Template Haskell package separate
is that we need to record dependency on the package, even if no TH module
is imported. So we carry round (another) mutable variable tcg_th_used in
the tyepchecker monad, and zap it when $(...) and [| ... |] are used.
I did a little tidy-up and documentation in ListSetOps too
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some small steps in the direction of making GHC useable as a library:
- The ErrMsg type is now richer: we keep the location info and the
PrintUnqualified separate until the message is printed out, and
messages have a short summary and "extra info", where the extra
info is used for things like the context info in the typechecker
(stuff that you don't normally want to see in a more visual setting,
where the context is obvious because you're looking at the code).
- hscMain now takes an extra argument of type (Messages -> IO ()),
which says what to do with the error messages. In normal usage,
we just pass ErrUtils.printErrorsAndWarnings, but eg. a development
environment will want to do something different. The direction we
need to head in is for hscMain to *never* do any output to
stdout/stderr except via abstractions like this.
|
| |
|
|
| |
Remove extra space in 'Not in scope' error message.
|