summaryrefslogtreecommitdiff
path: root/compiler/rename/RnSource.lhs
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix vectorisation of classesManuel M T Chakravarty2012-01-161-1/+1
| | | | | | - Make sure that we have no implicit names in ifaces - Any vectorisation info makes a module an orphan module - Allow 'Show' in vectorised code without vectorising it for the moment
* Implemnt Trac #5712: show method for infix GADT constructorsSimon Peyton Jones2011-12-231-16/+36
| | | | | This is a tiny feature improvement; see the ticket. I have updated the user manual too.
* Allow type signatures in instance decls (Trac #5676)Simon Peyton Jones2011-12-121-15/+23
| | | | | | | | | | | This new feature-ette, enable with -XInstanceSigs, lets you give a type signature in an instance declaration: instance Eq Int where (==) :: Int -> Int -> Bool (==) = ...blah... Scoped type variables work too.
* Fix newtype wrapper for 'PData[s] (Wrap a)' and fix VECTORISE type and ↵Manuel M T Chakravarty2011-11-251-3/+3
| | | | | | | | instance pragmas * Correct usage of new type wrappers from MkId * 'VECTORISE [SCALAR] type T = S' didn't work correctly across module boundaries * Clean up 'VECTORISE SCALAR instance'
* Changes to the kind checkerJose Pedro Magalhaes2011-11-161-2/+1
| | | | | | | | | | | | | We now always check against an expected kind. When we really don't know what kind to expect, we match against a new meta kind variable. Also, we are more explicit about tuple sorts: HsUnboxedTuple -> Produced by the parser HsBoxedTuple -> Certainly a boxed tuple HsConstraintTuple -> Certainly a constraint tuple HsBoxedOrConstraintTuple -> Could be a boxed or a constraint tuple. Produced by the parser only, disappears after type checking
* Add dependencies on all .hs-boot TyCons in rnTyClDeclsJose Pedro Magalhaes2011-11-161-28/+69
|
* New kind-polymorphic coreJose Pedro Magalhaes2011-11-111-45/+64
| | | | | | | | | This big patch implements a kind-polymorphic core for GHC. The current implementation focuses on making sure that all kind-monomorphic programs still work in the new core; it is not yet guaranteed that kind-polymorphic programs (using the new -XPolyKinds flag) will work. For more information, see http://haskell.org/haskellwiki/GHC/Kinds
* Use -fwarn-tabs when validatingIan Lynagh2011-11-041-0/+7
| | | | | We only use it for "compiler" sources, i.e. not for libraries. Many modules have a -fno-warn-tabs kludge for now.
* VECTORISE pragmas for type classes and instancesManuel M T Chakravarty2011-10-311-0/+12
| | | | * Frontend support (not yet used in the vectoriser)
* Refactor the way in which type (and other) signatures are renamedSimon Peyton Jones2011-10-211-3/+2
| | | | | | | This was a trickier change than I had anticipated, but I think it's considerably tidier now. Fixes Trac #5533.
* Fully implement for VECTORISE type pragmas (non-SCALAR).Manuel M T Chakravarty2011-10-101-9/+8
|
* Handle newtypes and type functions correctly in FFI types; fixes #3008Ian Lynagh2011-10-011-4/+4
| | | | | | You can now use type functions in FFI types. Newtypes are now only looked through if the constructor is in scope.
* Tidy up the shape-checking for instance typesSimon Peyton Jones2011-09-291-2/+2
| | | | | | (in instance and standalone deriving decls) Fixes Trac #5513.
* Fix scoping for RHS of associated type decls (fixes Trac #5515)Simon Peyton Jones2011-09-291-16/+26
| | | | | | | | | | | We should not allow things like class C a b where type F a :: * instance C (p,q) r where type F (p,q) = r -- No! fvs(rhs) should be a subset -- of fvs(lhs)
* move AvailInfo and related things into its own moduleSimon Marlow2011-09-211-5/+4
|
* Add support for all top-level declarations to GHCiSimon Marlow2011-09-211-1/+2
| | | | | | | | | | | | | | | | This is work mostly done by Daniel Winograd-Cort during his internship at MSR Cambridge, with some further refactoring by me. This commit adds support to GHCi for most top-level declarations that can be used in Haskell source files. Class, data, newtype, type, instance are all supported, as are Type Family-related declarations. The current set of declarations are shown by :show bindings. As with variable bindings, entities bound by newer declarations shadow earlier ones. Tests are in testsuite/tests/ghci/scripts/ghci039--ghci054. Documentation to follow.
* Merge branch 'no-pred-ty'Max Bolingbroke2011-09-091-3/+3
|\ | | | | | | | | | | | | | | | | | | Conflicts: compiler/iface/BuildTyCl.lhs compiler/iface/MkIface.lhs compiler/iface/TcIface.lhs compiler/typecheck/TcTyClsDecls.lhs compiler/types/Class.lhs compiler/utils/Util.lhs
| * Implement -XConstraintKindMax Bolingbroke2011-09-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Basically as documented in http://hackage.haskell.org/trac/ghc/wiki/KindFact, this patch adds a new kind Constraint such that: Show :: * -> Constraint (?x::Int) :: Constraint (Int ~ a) :: Constraint And you can write *any* type with kind Constraint to the left of (=>): even if that type is a type synonym, type variable, indexed type or so on. The following (somewhat related) changes are also made: 1. We now box equality evidence. This is required because we want to give (Int ~ a) the *lifted* kind Constraint 2. For similar reasons, implicit parameters can now only be of a lifted kind. (?x::Int#) => ty is now ruled out 3. Implicit parameter constraints are now allowed in superclasses and instance contexts (this just falls out as OK with the new constraint solver) Internally the following major changes were made: 1. There is now no PredTy in the Type data type. Instead GHC checks the kind of a type to figure out if it is a predicate 2. There is now no AClass TyThing: we represent classes as TyThings just as a ATyCon (classes had TyCons anyway) 3. What used to be (~) is now pretty-printed as (~#). The box constructor EqBox :: (a ~# b) -> (a ~ b) 4. The type LCoercion is used internally in the constraint solver and type checker to represent coercions with free variables of type (a ~ b) rather than (a ~# b)
* | Implement associated type defaultsMax Bolingbroke2011-09-091-5/+9
|/ | | | | | | | | | | | | | | | | | | Basically, now you can write: class Cls a where type Typ a type Typ a = Just a And now if an instance does not specify an explicit associated type instance, one will be generated afresh based on that default. So for example this instance: instance Cls Int where Will be equivalent to this one: instance Cls Int where type Typ Int = Just Int
* Two small further extensions to associated typesSimon Peyton Jones2011-09-011-7/+2
| | | | | | | | | | | | | | | | | | | | | a) Allow multiple AT decls for in a single instance b) Allow a free type parameter to be instantiated Example class C a where type T a x :: * data A data B instance C Int where type T Int A = Int type T Int B = Bool There is no reason to prohibit this, and as we move towards a proper kind system it may even be useful. I also updated the documentation to cover this change and the previous one of allowing free type parameters for associated families.
* Allow associated types to have fresh parametersSimon Peyton Jones2011-09-011-106/+93
| | | | | | | | | | | | | | | | | This patch allows class C a where type T a b :: * instance C Int type T Int b = b -> b That is, T has a type index 'b' that is not one of the class variables. On the way I did a good deal of refactoring (as usual), especially in TcInstDcls.tcLocalInstDecl1, which checks for consistent instantiation of the class instance and the type instance. Less code, more expressiveness. See Note [Checking consistent instantiation]
* Functions and types can now be post-hoc vectorised; i.e., in modules where ↵Manuel M T Chakravarty2011-08-241-3/+3
| | | | | | | | | they are not declared, but only imported - Types already gained this functionality already in a previous commit - This commit adds the capability for functions This is a crucial step towards being able to use the standard Prelude, instead of a special vectorised one.
* Merge branch 'master' of http://darcs.haskell.org/ghcSimon Peyton Jones2011-08-221-2/+9
|\
| * Until the type checker can use vectorised signatures, we restrict the RHS of ↵Manuel M T Chakravarty2011-08-201-2/+9
| | | | | | | | | | | | VECTORISE pragmas to be a single identifier only. - This removes the need to be careful about the order of dictionaries during type inference. A property that is too fragile to try to maintain in the type checker.
* | A batch of changes related to the handling of binders in instance declsSimon Peyton Jones2011-08-221-114/+91
|/ | | | | | | | | | | | | | | | The issue is that in instnace C T where data S = ... f = ... neither S nor f is really a binder; they are *occurrences*. Moreover Haskell dictates that these particular occurrences are disambiguated by looking at the class whose instance they occur in. Some of this was not handled right for associated types. And RnNames.getLocalNonValBinders was a bit messhy; this patch tidies it up. (And thenM is finally gone from RnSource.)
* Add VECTORISE [SCALAR] type pragmaManuel M T Chakravarty2011-08-191-6/+19
| | | | | | | | | - Pragma to determine how a given type is vectorised - At this stage only the VECTORISE SCALAR variant is used by the vectoriser. - '{-# VECTORISE SCALAR type t #-}' implies that 't' cannot contain parallel arrays and may be used in vectorised code. However, its constructors can only be used in scalar code. We use this, e.g., for 'Int'. - May be used on imported types See also http://hackage.haskell.org/trac/ghc/wiki/DataParallel/VectPragma
* A little extra tracingSimon Peyton Jones2011-08-051-0/+1
|
* Fix a long-standing bug in HsUtils.hsTyClDeclBindersSimon Peyton Jones2011-08-051-1/+1
| | | | | | | | | We were returning the tycon of a type family *instance* as a binder, and it just isn't! Consequential tidy-ups follow. I tripped over this on the way to something else. I'm not sure it was causing a problem, but it is Plainly Wrong.
* Change the representation of export lists in .hi filesSimon Peyton Jones2011-08-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Currently export list in .hi files are partitioned by module export M T(C1,C2) N f,g In each list we only have OccNames, all assumed to come from the parent module M or N resp. This patch changes the representatation so that export lists have full Names: export M.T(M.C1,M.C2), N.f, N.g Numerous advatages * AvailInfo no longer needs to be parameterised; it always contains Names * Fixes Trac #5306. This was the main provocation * Less to-and-fro conversion when reading interface files It's all generally simpler. Interface files should not get bigger, becuase they have a nice compact representation for Names.
* Report on unused type variables (fixes #5331)Simon Peyton Jones2011-07-201-6/+10
| | | | | | | We were doing this already for explicit types like f :: forall a. Int but not for constructor declarations. This patch makes it consistent.
* Just renaming a couple of functionsIan Lynagh2011-07-141-1/+1
|
* Merge branch 'master' of http://darcs.haskell.org/ghcDavid Waern2011-06-131-0/+4
|\
| * Added a pragma {-# NOVECTORISE f #-} that suppresses vectorisation of ↵Manuel M T Chakravarty2011-06-131-0/+4
| | | | | | | | toplevel variable 'f'.
* | Change TypeSig and GenericSig to take a list of names (fixes #1595).David Waern2011-06-101-1/+1
|/ | | | | This is a merge of a patch contributed by Michal Terepeta and the recent generics changes.
* Remove HsNumTy and TypePati.Jose Pedro Magalhaes2011-05-041-9/+5
| | | | They belonged to the old generic deriving mechanism, so they can go. Adapted a lot of code as a consequence.
* Merge branch 'master' of http://darcs.haskell.org/ghc into ghc-genericsJose Pedro Magalhaes2011-04-271-1/+1
|\
| * Add missing eol marker in RnSource.lhsDavid Terei2011-04-261-1/+1
| |
* | Initial commit for Pedro's new generic default methodssimonpj2011-04-121-11/+0
|/ | | | | (See his Haskell Symposium 2010 paper "A generic deriving mechaism for Haskell")
* Added a VECTORISE pragmaManuel M T Chakravarty2011-02-201-7/+31
| | | | | | | | | | | | | | | - Added a pragma {-# VECTORISE var = exp #-} that prevents the vectoriser from vectorising the definition of 'var'. Instead it uses the binding '$v_var = exp' to vectorise 'var'. The vectoriser checks that the Core type of 'exp' matches the vectorised Core type of 'var'. (It would be quite complicated to perform that check in the type checker as the vectorisation of a type needs the state of the VM monad.) - Added parts of a related VECTORISE SCALAR pragma - Documented -ddump-vect - Added -ddump-vt-trace - Some clean up
* Do dependency analysis when kind-checking type declarationssimonpj@microsoft.com2011-01-101-11/+52
| | | | | | | | | | | | | | | | | | | | | This patch fixes Trac #4875. The main point is to do dependency analysis on type and class declarations, and kind-check them in dependency order, so as to improve error messages. This patch means that a few programs that would typecheck before won't typecheck any more; but before we were (naughtily) going beyond Haskell 98 without any language-extension flags, and Trac #4875 convinces me that doing so is a Bad Idea. Here's an example that won't typecheck any more data T a b = MkT (a b) type F k = T k Maybe If you look at T on its own you'd default 'a' to kind *->*; and then kind-checking would fail on F. But GHC currently accepts this program beause it looks at the *occurrences* of T.
* Implement auto-specialisation of imported Idssimonpj@microsoft.com2010-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This big-ish patch arranges that if an Id 'f' is * Type-class overloaded f :: Ord a => [a] -> [a] * Defined with an INLINABLE pragma {-# INLINABLE f #-} * Exported from its defining module 'D' then in any module 'U' that imports D 1. Any call of 'f' at a fixed type will generate (a) a specialised version of f in U (b) a RULE that rewrites unspecialised calls to the specialised on e.g. if the call is (f Int dOrdInt xs) then the specialiser will generate $sfInt :: [Int] -> [Int] $sfInt = <code for f, imported from D, specialised> {-# RULE forall d. f Int d = $sfInt #-} 2. In addition, you can give an explicit {-# SPECIALISE -#} pragma for the imported Id {-# SPECIALISE f :: [Bool] -> [Bool] #-} This too generates a local specialised definition, and the corresponding RULE The new RULES are exported from module 'U', so that any module importing U will see the specialised versions of 'f', and will not re-specialise them. There's a flag -fwarn-auto-orphan that warns you if the auto-generated RULES are orphan rules. It's not in -Wall, mainly to avoid lots of error messages with existing packages. Main implementation changes - A new flag on a CoreRule to say if it was auto-generated. This is persisted across interface files, so there's a small change in interface file format. - Quite a bit of fiddling with plumbing, to get the {-# SPECIALISE #-} pragmas for imported Ids. In particular, a new field tgc_imp_specs in TcGblEnv, to keep the specialise pragmas for imported Ids between the typechecker and the desugarer. - Some new code (although surprisingly little) in Specialise, to deal with calls of imported Ids
* Remove use of lambda with a refutable patternsimonpj@microsoft.com2010-09-231-1/+2
|
* Add separate functions for querying DynFlag and ExtensionFlag optionsIan Lynagh2010-09-181-3/+3
| | | | and remove the temporary DOpt class workaround.
* Super-monster patch implementing the new typechecker -- at lastsimonpj@microsoft.com2010-09-131-1/+1
| | | | | | | | | This major patch implements the new OutsideIn constraint solving algorithm in the typecheker, following our JFP paper "Modular type inference with local assumptions". Done with major help from Dimitrios Vytiniotis and Brent Yorgey.
* Separate the language flags from the other DynFlag'sIan Lynagh2010-07-241-1/+1
|
* Refactoring of hsXxxBinderssimonpj@microsoft.com2010-05-061-3/+2
| | | | | | This patch moves various functions that extract the binders from a HsTyClDecl, HsForeignDecl etc into HsUtils, and gives them consistent names.
* Make tcg_dus behave more sanely; fixes a mkUsageInfo panicsimonpj@microsoft.com2010-05-061-28/+31
| | | | | | | | | | | | | The tcg_dus field used to contain *uses* of type and class decls, but not *defs*. That was inconsistent, and it really went wrong for Template Haskell bracket. What happened was that foo = [d| data A = A f :: A -> A f x = x |] would find a "use" of A when processing the top level of the module, which in turn led to a mkUsageInfo panic in MkIface. The cause was the fact that the tcg_dus for the nested quote didn't have defs for A.
* Add a HsExplicitFlag to SpliceDecl, to improve Trac #4042simonpj@microsoft.com2010-05-061-1/+12
| | | | | | | | | | | | | | The issue here is that g :: A -> A f data A = A is treated as if you'd written $(f); that is the call of f is a top-level Template Haskell splice. This patch makes sure that we *first* check the -XTemplateHaskellFlag and bleat about a parse error if it's off. Othewise we get strange seeing "A is out of scope" errors.
* Fix Trac #3955: renamer and type variablessimonpj@microsoft.com2010-04-091-43/+38
| | | | | | | | The renamer wasn't computing the free variables of a type declaration properly. This patch refactors a bit, and makes it more robust, fixing #3955 and several other closely-related bugs. (We were omitting some free variables and that could just possibly lead to a usage-version tracking error.
* Refactor part of the renamer to fix Trac #3901simonpj@microsoft.com2010-03-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This one was bigger than I anticipated! The problem was that were were gathering the binders from a pattern before renaming -- but with record wild-cards we don't know what variables are bound by C {..} until after the renamer has filled in the "..". So this patch does the following * Change all the collect-X-Binders functions in HsUtils so that they expect to only be called *after* renaming. That means they don't need to return [Located id] but just [id]. Which turned out to be a very worthwhile simplification all by itself. * Refactor the renamer, and in ptic RnExpr.rnStmt, so that it doesn't need to use collectLStmtsBinders on pre-renamed Stmts. * This in turn required me to understand how GroupStmt and TransformStmts were renamed. Quite fiddly. I rewrote most of it; result is much shorter. * In doing so I flattened HsExpr.GroupByClause into its parent GroupStmt, with trivial knock-on effects in other files. Blargh.