summaryrefslogtreecommitdiff
path: root/compiler/iface/BuildTyCl.lhs
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove unused importsIan Lynagh2009-07-071-3/+0
|
* Make record selectors into ordinary functionssimonpj@microsoft.com2009-01-021-21/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This biggish patch addresses Trac #2670. The main effect is to make record selectors into ordinary functions, whose unfoldings appear in interface files, in contrast to their previous existence as magic "implicit Ids". This means that the usual machinery of optimisation, analysis, and inlining applies to them, which was failing before when the selector was somewhat complicated. (Which it can be when strictness annotations, unboxing annotations, and GADTs are involved.) The change involves the following points * Changes in Var.lhs to the representation of Var. Now a LocalId can have an IdDetails as well as a GlobalId. In particular, the information that an Id is a record selector is kept in the IdDetails. While compiling the current module, the record selector *must* be a LocalId, so that it participates properly in compilation (free variables etc). This led me to change the (hidden) representation of Var, so that there is now only one constructor for Id, not two. * The IdDetails is persisted into interface files, so that an importing module can see which Ids are records selectors. * In TcTyClDecls, we generate the record-selector bindings in renamed, but not typechecked form. In this way, we can get the typechecker to add all the types and so on, which is jolly helpful especially when GADTs or type families are involved. Just like derived instance declarations. This is the big new chunk of 180 lines of code (much of which is commentary). A call to the same function, mkAuxBinds, is needed in TcInstDcls for associated types. * The typechecker therefore has to pin the correct IdDetails on to the record selector, when it typechecks it. There was a neat way to do this, by adding a new sort of signature to HsBinds.Sig, namely IdSig. This contains an Id (with the correct Name, Type, and IdDetails); the type checker uses it as the binder for the final binding. This worked out rather easily. * Record selectors are no longer "implicit ids", which entails changes to IfaceSyn.ifaceDeclSubBndrs HscTypes.implicitTyThings TidyPgm.getImplicitBinds (These three functions must agree.) * MkId.mkRecordSelectorId is deleted entirely, some 300+ lines (incl comments) of very error prone code. Happy days. * A TyCon no longer contains the list of record selectors: algTcSelIds is gone The renamer is unaffected, including the way that import and export of record selectors is handled. Other small things * IfaceSyn.ifaceDeclSubBndrs had a fragile test for whether a data constructor had a wrapper. I've replaced that with an explicit flag in the interface file. More robust I hope. * I renamed isIdVar to isId, which touched a few otherwise-unrelated files.
* Avoid nasty name clash with associated data types (fixes Trac #2888)simonpj@microsoft.com2008-12-301-1/+8
| | | | | | | | | | | | | The main bug was in TcHsType; see Note [Avoid name clashes for associated data types]. However I did a bit of re-factoring while I was abouut it. I'm still a but unhappy with the use of TyCon.setTyConArgPoss; it'd be better to construct the TyCon correctly in the first place. But that means passing an extra parameter to tcTyDecl1... maybe we should do this.
* Allow type families to use GADT syntax (and be GADTs)simonpj@microsoft.com2008-09-231-5/+7
| | | | | | | | | | | | | | We've always intended to allow you to use GADT syntax for data families: data instance T [a] where T1 :: a -> T [a] and indeed to allow data instances to *be* GADTs data intsance T [a] where T1 :: Int -> T [Int] T2 :: a -> b -> T [(a,b)] This patch fixes the renamer and type checker to allow this.
* Comments only: replace ":=:" by "~" (notation for equality predicates)simonpj@microsoft.com2008-09-201-1/+1
|
* Remove dataConInstOrigDictsAndArgTyssimonpj@microsoft.com2008-09-101-5/+8
| | | | | | | This suspicious function had just one call, in BuildTyCl.mkNewTyConRhs. I've done it another way now, which is tidier.
* Fix Trac #2412: type synonyms and hs-boot recursionsimonpj@microsoft.com2008-08-111-4/+5
| | | | | | | | | | | | | | | | | | | | | | Max Bolingbroke found this awkward bug, which relates to the way in which hs-boot files are handled. --> HEADS UP: interface file format change: recompile everything! When we import a type synonym, we want to *refrain* from looking at its RHS until we've "tied the knot" in the module being compiled. (Reason: the type synonym might ultimately loop back to the module being compiled.) To achieve this goal we need to know the *kind* of the synonym without looking at its RHS. And to do that we need its kind recorded in the interface file. I slightly refactored the way that the IfaceSyn data constructor fields work, eliminating the previous tricky re-use of the same field as either a type or a kind. See Note [Synonym kind loop] in TcIface
* Remove a duplicate module import in BuildTyClIan Lynagh2008-05-041-1/+0
|
* Make BuildTyCl warning-freeIan Lynagh2008-05-041-8/+1
|
* Fix Trac #2238: do not use newtype for a class with equality predicatessimonpj@microsoft.com2008-04-281-9/+34
| | | | | See Note [Class newtypes and equality predicates] in this module.
* Don't expose the unfolding of dictionary selectors without -Osimonpj@microsoft.com2008-03-061-4/+7
| | | | | | | | | | | | | | | | | | | | | When compiling without -O we were getting code like this f x = case GHC.Base.$f20 of :DEq eq neq -> eq x x But because of the -O the $f20 dictionary is not available, so exposing the dictionary selector was useless. Yet it makes the code bigger! Better to get f x = GHC.Base.== GHC.Bsae.$f20 x x This patch suppresses the implicit unfolding for dictionary selectors when compiling without -O. We could do the same for other implicit Ids, but this will do for now. There should be no effect when compiling with -O. Programs should be smaller without -O and may run a tiny bit slower.
* Monadify iface/BuildTyCl: use returnTwan van Laarhoven2008-01-171-1/+1
|
* Improve handling of newtypes (fixes Trac 1495)simonpj@microsoft.com2007-12-211-38/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a few places we want to "look through" newtypes to get to the representation type. But we need to be careful that we don't fall into an ininite loop with e.g. newtype T = MkT T The old mechansim for doing this was to have a field nt_rep, inside a newtype TyCon, that gave the "ultimate representation" of the type. But that failed for Trac 1495, which looked like this: newtype Fix a = Fix (a (Fix a)) data I a = I a Then, expanding the type (Fix I) went on for ever. The right thing to do seems to be to check for loops when epxanding the *type*, rather than in the *tycon*. This patch does that, - Removes nt_rep from TyCon - Make Type.repType check for loops See Note [Expanding newtypes] in Type.lhs. At the same time I also fixed a bug for Roman, where newtypes were not being expanded properly in FamInstEnv.topNormaliseType. This function and Type.repType share a common structure. Ian, see if this merges easily to the branch If not, I don't think it's essential to fix 6.8
* 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
|
* Type checking for type synonym familiesManuel M T Chakravarty2007-08-281-27/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces type checking for type families of which associated type synonyms are a special case. E.g. type family Sum n m type instance Sum Zero n = n type instance Sum (Succ n) m = Succ (Sum n m) where data Zero -- empty type data Succ n -- empty type In addition we support equational constraints of the form: ty1 ~ ty2 (where ty1 and ty2 are arbitrary tau types) in any context where type class constraints are already allowed, e.g. data Equals a b where Equals :: a ~ b => Equals a b The above two syntactical extensions are disabled by default. Enable with the -XTypeFamilies flag. For further documentation about the patch, see: * the master plan http://hackage.haskell.org/trac/ghc/wiki/TypeFunctions * the user-level documentation http://haskell.org/haskellwiki/GHC/Indexed_types The patch is mostly backwards compatible, except for: * Some error messages have been changed slightly. * Type checking of GADTs now requires a bit more type declarations: not only should the type of a GADT case scrutinee be given, but also that of any identifiers used in the branches and the return type. Please report any unexpected behavior and incomprehensible error message for existing code. Contributors (code and/or ideas): Tom Schrijvers Manuel Chakravarty Simon Peyton-Jones Martin Sulzmann with special thanks to Roman Leshchinskiy
* Fix a bug in MatchCon, and clarify what dataConInstOrigArgTys doesLemmih2007-06-071-0/+2
| | | | | | | | | | | There was an outright bug in MatchCon.matchOneCon, in the construction of arg_tys. Easily fixed. It never showed up becuase the arg_tys are only used in WildPats, and they in turn seldom have their types looked (except by hsPatType). So I can't make a test case for htis. While I was investigating, I added a bit of clarifation and invariant-checking to dataConInstOrigArgTys and dataConInstArgTys
* Remove the distinction between data and newtype familiesManuel M T Chakravarty2007-05-111-5/+2
| | | | | | | | | - This patch removes "newtype family" declarations. - "newtype instance" declarations can now be instances of data families - This also fixes bug #1331 ** This patch changes the interface format. All libraries and all of ** ** Stage 2 & 3 need to be re-compiled from scratch. **
* Warning fix for unused and redundant importsMichael D. Adams2007-05-101-1/+0
|
* Generating synonym instance representation tyconsManuel M T Chakravarty2007-04-251-32/+48
| | | | | | | | - Type synonym instances are turned into representation synonym tycons - They are entered into the pool of family instances (FamInst environments) in the same way as data/newtype instances - Still missing is writing the parent tycon information into ifaces and various well-formedness checks.
* Moved argument position info of ATs into tycon rhs infoManuel M T Chakravarty2007-02-231-3/+3
|
* Log message for: Fix a nasty recursive loop in typechecking interface filessimonpj@microsoft.com2007-01-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | (Alas, Darcs failed to record my log-message for the above patch, so this patch is an attempt to add the log message retrospectively.) Roman found a case where the type-checker for interface files would go into a loop. Here it is: module BarAT where class Foo a where data FooT a :: * int :: FooT a -> Int module Baz where import BarAT foo :: FooT Int -> Int foo = foo The trouble turned out to be that Foo gives rise to a *newtype*, and using a newtpe caused a little bit too much strictness in BuildTyCl.mkNewTyConRhs. Specifically, mkNewTypeCoercion did pattern matching, which forced the call to eta_reduce in mkNewTyConRhs. This is all too delicate really. But for now I've fixed the bug, and added an explanatory comment. I'll add a test for it, in indexed-types/should_compile/ATLoop
* Fix a nasty recursive loop in typechecking interface filessimonpj@microsoft.com2007-01-111-6/+8
|
* Module header tidyup, phase 1Simon Marlow2006-10-111-28/+15
| | | | | | | | | | | | 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
* Remove Linear Implicit Parameters, and all their workssimonpj@microsoft.com2006-09-291-8/+6
| | | | | | | Linear implicit parameters have been in GHC quite a while, but we decided they were a mis-feature and scheduled them for removal. This patch does the job.
* Re-work the newtype-deriving supportsimonpj@microsoft.com2006-09-231-18/+19
| | | | | | | | | The newtype deriving mechanism is much trickier to support than it seems at first. Kevin didn't get it quite right when moving to FC, and I ended up re-writing quite a bit of it. I think it's right now, but I have not yet tested it thoroughly.
* Get of fam inst index in ifacesManuel M T Chakravarty2006-09-201-23/+14
| | | | | | | | | | | | | | Mon Sep 18 19:40:42 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Get of fam inst index in ifaces Fri Sep 8 16:31:26 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Get of fam inst index in ifaces - Removes the explicit index to get unique names for derived tycons for family instances again, following a suggestion by SPJ. - We now derive the coercion tycon name from the name of the representation tycon, which is in the iface anyways. *** WARNING: Change of interface file format! *** *** Recompile from scratch! ***
* Straightened out implicit coercions for indexed typesManuel M T Chakravarty2006-09-201-7/+7
| | | | | | | | | | | | | | | | | | | | | | | Mon Sep 18 19:35:24 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Straightened out implicit coercions for indexed types Mon Sep 4 23:46:14 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Straightened out implicit coercions for indexed types - HscTypes.implicitTyThings and LoadIface.ifaceDeclSubBndrs now include the coercion of indexed data/newtypes. - Name generation for the internal names of indexed data/newtypes now uses the same counter that generates the dfun unique indexes (ie, class and type instances are counted with the one counter). We could make this two separate counters if that's what's preferred. - The unique index of a data/newtype instances needs to go into the iface, so that we can generate the same names on slurping in the iface as when the original module was generated. This is a bit yucky, but I don't see a way to avoid that (other than putting the full blown internal tycon name and coercion name into the iface, which IMHO would be worse). - The predicate for when a datacon has a wrapper didn't take GADT equations nor whether it comes froma family instance into account. *** WARNING! This patch changed the interface file format. *** *** Please recompile from scratch. ***
* Introduce coercions for data instance declsManuel M T Chakravarty2006-09-201-23/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | Mon Sep 18 19:07:30 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Introduce coercions for data instance decls Tue Aug 22 20:33:46 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Introduce coercions for data instance decls - data instance declarations implicitly generate a coercion moving between the representation type and family instance type. - The coercion is *implicitly* generated when type checking both source and ifaces. Ie, we don't safe it in ifaces - this is really exactly as newtype coercions are handled. - The previous addition of the instance types to DataCons has been moved to the representation TyCon. This is more efficient as it is shared between all constructors of one representation tycon and it also gathers everything about data instances (family tycon, instance types, and coercion) in one place: the algTcParent field of TyCon. - The coercion is already used in the datacon wrappers, but not yet during type checking pattern matching of indexed data types. - The code has only been lightly tested, but doesn't seem to break features not related to indexed types. For indexed data types only the pattern matching tc code (in TcPat.tcConPat) and some well-formedness checks are still missing. And there will surely be some bugs to fix. (newtypes still require some more work.) ** WARNING: Interface file format changed! ** ** Recompile from scratch! **
* Extend TyCons and DataCons to represent data instance declsManuel M T Chakravarty2006-09-201-8/+23
| | | | | | | | | | | | | | | Mon Sep 18 19:05:18 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Extend TyCons and DataCons to represent data instance decls Fri Aug 18 19:11:37 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Extend TyCons and DataCons to represent data instance decls - This is a faily involved patch, but it is not entirely complete: + The data con wrapper code for instance data cons needs to apply the coercions (which we still have to generate). + There are still bugs, but it doesn't seem to affect the compilation of code that doesn't use type families. ** WARNING: Yet another change of the iface format. ** ** Recompile everything. **
* Extend Class.Class to include the TyCons of ATsManuel M T Chakravarty2006-09-201-4/+8
| | | | | | | Mon Sep 18 18:58:51 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Extend Class.Class to include the TyCons of ATs Wed Aug 16 16:15:31 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Extend Class.Class to include the TyCons of ATs
* Extended TyCon and friends to represent family declarationsManuel M T Chakravarty2006-09-201-9/+23
| | | | | | | Mon Sep 18 18:50:35 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Extended TyCon and friends to represent family declarations Tue Aug 15 16:52:31 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Extended TyCon and friends to represent family declarations
* fix bugs, add boolean flag to identify coercion variablesManuel M T Chakravarty2006-09-201-2/+11
| | | | | | | | Mon Sep 18 16:41:32 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * fix bugs, add boolean flag to identify coercion variables Sun Aug 6 17:04:02 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * fix bugs, add boolean flag to identify coercion variables Tue Jul 25 06:20:05 EDT 2006 kevind@bu.edu
* some bug-fixes, newtype deriving might work nowManuel M T Chakravarty2006-09-201-1/+1
| | | | | | | | Mon Sep 18 14:33:01 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * some bug-fixes, newtype deriving might work now Sat Aug 5 21:29:28 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * some bug-fixes, newtype deriving might work now Tue Jul 11 12:16:13 EDT 2006 kevind@bu.edu
* newtype fixes, coercions for non-recursive newtypes now optionalManuel M T Chakravarty2006-09-201-8/+10
| | | | | | | | Mon Sep 18 14:24:27 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * newtype fixes, coercions for non-recursive newtypes now optional Sat Aug 5 21:19:58 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * newtype fixes, coercions for non-recursive newtypes now optional Fri Jul 7 06:11:48 EDT 2006 kevind@bu.edu
* Remove argument variance info of tyconsManuel M T Chakravarty2006-09-181-9/+9
| | | | | | | | | | Fri Aug 11 13:53:24 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au> * Remove argument variance info of tycons - Following SPJ's suggestion, this patch removes the variance information from type constructors. This information was computed, but never used. ** WARNING: This patch changes the format of interface files ** ** You will need to rebuild from scratch. **
* Massive patch for the first months work adding System FC to GHC #16Manuel M T Chakravarty2006-08-041-49/+64
| | | | | | | | 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.
* Reorganisation of the source treeSimon Marlow2006-04-071-0/+256
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.