1. 14 Feb, 2002 1 commit
  2. 11 Feb, 2002 1 commit
    • chak's avatar
      [project @ 2002-02-11 08:20:38 by chak] · 10fcd78c
      chak authored
      		       * Merging from ghc-ndp-branch *
      This commit merges the current state of the "parallel array extension" and
      includes the following:
      * (Almost) completed Milestone 1:
        - The option `-fparr' activates the H98 extension for parallel arrays.
        - These changes have a high likelihood of conflicting (in the CVS sense)
          with other changes to GHC and are the reason for merging now.
        - ToDo: There are still some (less often used) functions not implemented in
      	  `PrelPArr' and a mechanism is needed to automatically import
      	  `PrelPArr' iff `-fparr' is given.  Documentation that should go into
      	  the Commentary is currently in `ghc/compiler/ndpFlatten/TODO'.
      * Partial Milestone 2:
        - The option `-fflatten' activates the flattening transformation and `-ndp'
          selects the "ndp" way (where all libraries have to be compiled with
          flattening).  The way option `-ndp' automagically turns on `-fparr' and
        - Almost all changes are in the new directory `ndpFlatten' and shouldn't
          affect the rest of the compiler.  The only exception are the options and
          the points in `HscMain' where the flattening phase is called when
          `-fflatten' is given.
        - This isn't usable yet, but already implements function lifting,
          vectorisation, and a new analysis that determines which parts of a module
          have to undergo the flattening transformation.  Missing are data structure
          and function specialisation, the unboxed array library (including fusion
          rules), and lots of testing.
      I have just run the regression tests on the thing without any problems.  So,
      it seems, as if we haven't broken anything crucial.
  3. 20 Dec, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-12-20 11:19:05 by simonpj] · 91c750cb
      simonpj authored
      	More type system extensions (for John Hughes)
      1.  Added a brand-new extension that lets you derive ARBITRARY CLASSES
      for newtypes.  Thus
      	newtype Age = Age Int deriving( Eq, Ord, Shape, Ix )
      The idea is that the dictionary for the user-defined class Shape Age
      is *identical* to that for Shape Int, so there is really no deriving
      work to do.   This saves you writing the very tiresome instance decl:
      	instance Shape Age where
      	   shape_op1 (Age x) = shape_op1 x
      	   shape_op2 (Age x1) (Age x2) = shape_op2 x1 x2
      It's more efficient, too, becuase the Shape Age dictionary really
      will be identical to the Shape Int dictionary.
      There's an exception for Read and Show, because the derived instance
      *isn't* the same.
      There is a complication where higher order stuff is involved.  Here is
      the example John gave:
         class StateMonad s m | m -> s where ...
         newtype Parser tok m a = Parser (State [tok] (Failure m) a)
      			  deriving( Monad, StateMonad )
      Then we want the derived instance decls to be
         instance Monad (State [tok] (Failure m)) => Monad (Parser tok m)
         instance StateMonad [tok] (State [tok] (Failure m))
      	 => StateMonad [tok] (Parser tok m)
      John is writing up manual entry for all of this, but this commit
      implements it.   I think.
      2.  Added -fallow-incoherent-instances, and documented it.  The idea
      is that sometimes GHC is over-protective about not committing to a
      particular instance, and the programmer may want to say "commit anyway".
      Here's the example:
          class Sat a where
            dict :: a
          data EqD a = EqD {eq :: a->a->Bool}
          instance Sat (EqD a) => Eq a where
            (==) = eq dict
          instance Sat (EqD Integer) where
            dict = EqD{eq=(==)}
          instance Eq a => Sat (EqD a) where
            dict = EqD{eq=(==)}
          class Collection c cxt | c -> cxt where
            empty :: Sat (cxt a) => c a
            single :: Sat (cxt a) => a -> c a
            union :: Sat (cxt a) => c a -> c a -> c a
            member :: Sat (cxt a) => a -> c a -> Bool
          instance Collection [] EqD where
            empty = []
            single x = [x]
            union = (++)
            member = elem
      It's an updated attempt to model "Restricted Data Types", if you
      remember my Haskell workshop paper. In the end, though, GHC rejects
      the program (even with fallow-overlapping-instances and
      fallow-undecideable-instances), because there's more than one way to
      construct the Eq instance needed by elem.
      Yet all the ways are equivalent! So GHC is being a bit over-protective
      of me, really: I know what I'm doing and I would LIKE it to pick an
      arbitrary one. Maybe a flag fallow-incoherent-instances would be a
      useful thing to add?
  4. 29 Nov, 2001 1 commit
  5. 26 Nov, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-11-26 09:20:25 by simonpj] · 5e3f005d
      simonpj authored
      	Implement Rank-N types
      This commit implements the full glory of Rank-N types, using
      the Odersky/Laufer approach described in their paper
      	"Putting type annotations to work"
      In fact, I've had to adapt their approach to deal with the
      full glory of Haskell (including pattern matching, and the
      scoped-type-variable extension).  However, the result is:
      * There is no restriction to rank-2 types.  You can nest forall's
        as deep as you like in a type.  For example, you can write a type
      	p :: ((forall a. Eq a => a->a) -> Int) -> Int
        This is a rank-3 type, illegal in GHC 5.02
      * When matching types, GHC uses the cunning Odersky/Laufer coercion
        rules.  For example, suppose we have
      	q :: (forall c. Ord c => c->c) -> Int
        Then, is this well typed?
      	x :: Int
      	x = p q
        Yes, it is, but GHC has to generate the right coercion.  Here's
        what it looks like with all the big lambdas and dictionaries put in:
      	x = p (\ f :: (forall a. Eq a => a->a) ->
      		 q (/\c \d::Ord c -> f c (eqFromOrd d)))
        where eqFromOrd selects the Eq superclass dictionary from the Ord
        dicationary:		eqFromOrd :: Ord a -> Eq a
      * You can use polymorphic types in pattern type signatures.  For
      	f (g :: forall a. a->a) = (g 'c', g True)
        (Previously, pattern type signatures had to be monotypes.)
      * The basic rule for using rank-N types is that you must specify
        a type signature for every binder that you want to have a type
        scheme (as opposed to a plain monotype) as its type.
        However, you don't need to give the type signature on the
        binder (as I did above in the defn for f).  You can give it
        in a separate type signature, thus:
      	f :: (forall a. a->a) -> (Char,Bool)
      	f g = (g 'c', g True)
        GHC will push the external type signature inwards, and use
        that information to decorate the binders as it comes across them.
        I don't have a *precise* specification of this process, but I
        think it is obvious enough in practice.
      * In a type synonym you can use rank-N types too.  For example,
        you can write
      	type IdFun = forall a. a->a
      	f :: IdFun -> (Char,Bool)
      	f g = (g 'c', g True)
        As always, type synonyms must always occur saturated; GHC
        expands them before it does anything else.  (Still, GHC goes
        to some trouble to keep them unexpanded in error message.)
      The main plan is as before.  The main typechecker for expressions,
      tcExpr, takes an "expected type" as its argument.  This greatly
      improves error messages.  The new feature is that when this
      "expected type" (going down) meets an "actual type" (coming up)
      we use the new subsumption function
      which checks that the actual type can be coerced into the
      expected type (and produces a coercion function to demonstrate).
      The main new chunk of code is TcUnify.tcSub.  The unifier itself
      is unchanged, but it has moved from TcMType into TcUnify.  Also
      checkSigTyVars has moved from TcMonoType into TcUnify.
      Result: the new module, TcUnify, contains all stuff relevant
      to subsumption and unification.
      Unfortunately, there is now an inevitable loop between TcUnify
      and TcSimplify, but that's just too bad (a simple TcUnify.hi-boot
      All of this doesn't come entirely for free.  Here's the typechecker
      line count (INCLUDING comments)
      	Before	16,551
      	After	17,116
  6. 31 Oct, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-10-31 15:22:53 by simonpj] · 61bfd5dd
      simonpj authored
      	Improved handling of scoped type variables
      The main effect of this commit is to allow scoped type variables
      in pattern bindings, thus
      	(x::a, y::b) = e
      This was illegal, but now it's ok.  a and b have the same scope
      as x and y.
      On the way I beefed up the info inside a type variable
      (TcType.TyVarDetails; c.f. IdInfo.GlobalIdDetails) which
      helps to improve error messages. Hence the wide ranging changes.
      Pity about the extra loop from Var to TcType, but can't be helped.
  7. 14 Aug, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-08-14 06:35:56 by simonpj] · 2767767f
      simonpj authored
      1. Arrange that w/w records unfoldings
         And that the simplifier preserves them
      2. Greatly improve structure of checking user types in the typechecker
         Main changes:
      	TcMType.checkValidType checks for a valid type
      	TcMonoType.tcHsSigType uses checkValidType
      	Type and class decls use TcMonoType.tcHsType (which does not
      		check for validity) inside the knot in TcTyClsDecls,
      		and then runs TcTyDecls.checkValidTyCon
      		or TcClassDcl.checkValidClass to check for validity
      		once the knot is tied
  8. 13 Jul, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-07-13 13:29:56 by simonpj] · d4e38936
      simonpj authored
      	Tidy up the "syntax rebinding" story
      I found a bug in the code that dealt with re-binding implicit
      numerical syntax:
      	literals 	(fromInteger/fromRational)
      	negation	(negate)
      	n+k patterns	(minus)
      This is triggered by the -fno-implicit-prelude flag, and it
      used to be handled via the PrelNames.SyntaxMap.
      But I found a nicer way to do it that involves much less code,
      and doesn't have the bug.  The explanation is with
  9. 25 Jun, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-06-25 08:09:57 by simonpj] · d069cec2
      simonpj authored
      	Squash newtypes
      This commit squashes newtypes and their coerces, from the typechecker
      onwards.  The original idea was that the coerces would not get in the
      way of optimising transformations, but despite much effort they continue
      to do so.   There's no very good reason to retain newtype information
      beyond the typechecker, so now we don't.
      Main points:
      * The post-typechecker suite of Type-manipulating functions is in
      types/Type.lhs, as before.   But now there's a new suite in types/TcType.lhs.
      The difference is that in the former, newtype are transparent, while in
      the latter they are opaque.  The typechecker should only import TcType,
      not Type.
      * The operations in TcType are all non-monadic, and most of them start with
      "tc" (e.g. tcSplitTyConApp).  All the monadic operations (used exclusively
      by the typechecker) are in a new module, typecheck/TcMType.lhs
      * I've grouped newtypes with predicate types, thus:
      	data Type = TyVarTy Tyvar | ....
      		  | SourceTy SourceType
      	data SourceType = NType TyCon [Type]
      			| ClassP Class [Type]
      			| IParam Type
      [SourceType was called PredType.]  This is a little wierd in some ways,
      because NTypes can't occur in qualified types.   However, the idea is that
      a SourceType is a type that is opaque to the type checker, but transparent
      to the rest of the compiler, and newtypes fit that as do implicit parameters
      and dictionaries.
      * Recursive newtypes still retain their coreces, exactly as before. If
      they were transparent we'd get a recursive type, and that would make
      various bits of the compiler diverge (e.g. things which do type comparison).
      * I've removed types/Unify.lhs (non-monadic type unifier and matcher),
      merging it into TcType.
      Ditto typecheck/TcUnify.lhs (monadic unifier), merging it into TcMType.
  10. 13 Mar, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-03-13 14:58:25 by simonpj] · 788faebb
      simonpj authored
      	Nuke ClassContext
      This commit tidies up a long-standing inconsistency in GHC.
      The context of a class or instance decl used to be restricted
      to predicates of the form
      	C t1 .. tn
      	type ClassContext = [(Class,[Type])]
      but everywhere else in the compiler we used
      	type ThetaType = [PredType]
      where PredType can be any sort of constraint (= predicate).
      The inconsistency actually led to a crash, when compiling
      	class (?x::Int) => C a where {}
      I've tidied all this up by nuking ClassContext altogether, and using
      PredType throughout.  Lots of modified files, but all in
      more-or-less trivial ways.
      I've also added a check that the context of a class or instance
      decl doesn't include a non-inheritable predicate like (?x::Int).
      Other things
       * rename constructor 'Class' from type TypeRep.Pred to 'ClassP'
         (makes it easier to grep for)
       * rename constructor HsPClass  => HsClassP
      		      HsPIParam => HsIParam
  11. 08 Mar, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-03-08 12:07:38 by simonpj] · 51a571c0
      simonpj authored
      	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.
  12. 20 Feb, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-02-20 09:40:43 by simonpj] · 5e624292
      simonpj authored
      Decoupling the Prelude [HsExpr, HsLit, HsPat, ParseUtil, Parser.y, PrelNames,
      ~~~~~~~~~~~~~~~~~~~~~~  Rename, RnEnv, RnExpr, RnHsSyn, Inst, TcEnv, TcMonad,
      			TcPat, TcExpr]
      The -fno-implicit-prelude flag is meant to arrange that when you write
      you get
      	fromInt 3
      where 'fromInt' is whatever fromInt is in scope at the top level of
      the module being compiled.  Similarly for
      	* numeric patterns
      	* n+k patterns
      	* negation
      This used to work, but broke when we made the static/dynamic flag distinction.
      It's now tidied up a lot.  Here's the plan:
        - PrelNames contains sugarList :: SugarList, which maps built-in names
          to the RdrName that should replace them.  
        - The renamer makes a finite map :: SugarMap, which maps the built-in names
          to the Name of the re-mapped thing
        - The typechecker consults this map via tcLookupSyntaxId when it is doing
          numeric things
      At present I've only decoupled numeric syntax, since that is the main demand,
      but the scheme is much more robustly extensible than the previous method.
      As a result some HsSyn constructors don't need to carry names in them
      (notably HsOverLit, NegApp, NPlusKPatIn)
  13. 25 Jan, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-01-25 17:54:24 by simonpj] · 4e342297
      simonpj authored
      	   Mainly FunDeps (23 Jan 01)
      This commit re-engineers the handling of functional dependencies.
      A functional dependency is no longer an Inst; instead, the necessary
      dependencies are snaffled out of their Class when necessary.
      As part of this exercise I found that I had to re-work how to do generalisation
      in a binding group.  There is rather exhaustive documentation on the new Plan
      at the top of TcSimplify.
      	WARNING: I have compiled all the libraries with this new compiler
      		 and all looks well, but I have not run many programs.
      		 Things may break.  Let me know if so.
      The main changes are these:
      1.  typecheck/TcBinds and TcSimplify have a lot of changes due to the
          new generalisation and context reduction story.  There are extensive
          comments at the start of TcSimplify
      2.  typecheck/TcImprove is removed altogether.  Instead, improvement is
          interleaved with context reduction (until a fixpoint is reached).
          All this is done in TcSimplify.
      3.  types/FunDeps has new exports
      	* 'improve' does improvement, returning a list of equations
      	* 'grow' and 'oclose' close a list of type variables wrt a set of
      	  PredTypes, but in slightly different ways.  Comments in file.
      4.  I improved the way in which we check that main::IO t.  It's tidier now.
      In addition
      *   typecheck/TcMatches:
      	a) Tidy up, introducing a common function tcCheckExistentialPat
      	b) Improve the typechecking of parallel list comprehensions,
      	   which wasn't quite right before.  (see comments with tcStmts)
      	WARNING: (b) is untested!  Jeff, you might want to check.
      *   Numerous other incidental changes in the typechecker
      *   Manuel found that rules don't fire well when you have partial applications
          from overloading.  For example, we may get
      	f a (d::Ord a) = let m_g = g a d
      			 \y :: a -> ...(m_g (h y))...
          The 'method' m_g doesn't get inlined because (g a d) might be a redex.
          Yet a rule that looks like
      		g a d (h y) = ...
          won't fire because that doesn't show up.  One way out would be to make
          the rule matcher a bit less paranoid about duplicating work, but instead
          I've added a flag
          which controls whether we generate things like m_g in the first place.
          It's not clear that they are a win in the first place.
          The flag is actually consulted in Inst.tcInstId
  14. 03 Jan, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-01-03 11:18:51 by simonmar] · 20d387c4
      simonmar authored
      The typechecker's notion of "boxed" versus "unboxed" kind should
      really have been "unlifted" versus "lifted" instead.  It is illegal to
      unify an unlifted (but boxed) type with a polymorphic type variable,
      since an unlifted/boxed type is always assumed to be a pointer to the
      object itself, never a thunk or indirection.
      This commit removes isUnboxedType, and renames a bunch of things that
      were previously boxed/unboxed to unlifted/lifted.
  15. 17 Oct, 2000 1 commit
  16. 16 Oct, 2000 1 commit
  17. 12 Oct, 2000 1 commit
  18. 03 Oct, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-10-03 08:43:00 by simonpj] · 710e2074
      simonpj authored
      	Adding generics		SLPJ Oct 2000
      This big commit adds Hinze/PJ-style generic class definitions, based
      on work by Andrei Serjantov.  For example:
        class Bin a where
          toBin   :: a -> [Int]
          fromBin :: [Int] -> (a, [Int])
          toBin {| Unit |}    Unit	  = []
          toBin {| a :+: b |} (Inl x)   = 0 : toBin x
          toBin {| a :+: b |} (Inr y)   = 1 : toBin y
          toBin {| a :*: b |} (x :*: y) = toBin x ++ toBin y
          fromBin {| Unit |}    bs      = (Unit, bs)
          fromBin {| a :+: b |} (0:bs)  = (Inl x, bs')    where (x,bs') = fromBin bs
          fromBin {| a :+: b |} (1:bs)  = (Inr y, bs')    where (y,bs') = fromBin bs
          fromBin {| a :*: b |} bs  	  = (x :*: y, bs'') where (x,bs' ) = fromBin bs
      							  (y,bs'') = fromBin bs'
      Now we can say simply
        instance Bin a => Bin [a]
      and the compiler will derive the appropriate code automatically.
      		(About 9k lines of diffs.  Ha!)
      Generic related things
      * basicTypes/BasicTypes: The EP type (embedding-projection pairs)
      * types/TyCon:
      	An extra field in an algebraic tycon (genInfo)
      * types/Class, and hsSyn/HsBinds:
      	Each class op (or ClassOpSig) carries information about whether
      	it  	a) has no default method
      		b) has a polymorphic default method
      		c) has a generic default method
      	There's a new data type for this: Class.DefMeth
      * types/Generics:
      	A new module containing good chunk of the generic-related code
      	It has a .hi-boot file (alas).
      * typecheck/TcInstDcls, typecheck/TcClassDcl:
      	Most of the rest of the generics-related code
      * hsSyn/HsTypes:
      	New infix type form to allow types of the form
      		data a :+: b = Inl a | Inr b
      * parser/Parser.y, Lex.lhs, rename/ParseIface.y:
      	Deal with the new syntax
      * prelude/TysPrim, TysWiredIn:
      	Need to generate generic stuff for the wired-in TyCons
      * rename/RnSource RnBinds:
      	A rather gruesome hack to deal with scoping of type variables
      	from a generic patterns.  Details commented in the ClassDecl
      	case of RnSource.rnDecl.
      	Of course, there are many minor renamer consequences of the
      	other changes above.
      * lib/std/PrelBase.lhs
      	Data type declarations for Unit, :+:, :*:
      Slightly unrelated housekeeping
      * hsSyn/HsDecls:
      	ClassDecls now carry the Names for their implied declarations
      	(superclass selectors, tycon, etc) in a list, rather than
      	laid out one by one.  This simplifies code between the parser
      	and the type checker.
      * prelude/PrelNames, TysWiredIn:
      	All the RdrNames are now together in PrelNames.
      * utils/ListSetOps:
      	Add finite mappings based on equality and association lists (Assoc a b)
      	Move stuff from List.lhs that is related
  19. 28 Sep, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-09-28 13:04:14 by simonpj] · 861e836e
      simonpj authored
      	   Mainly PredTypes (28 Sept 00)
      Three things in this commit:
      	1.  Main thing: tidy up PredTypes
      	2.  Move all Keys into PrelNames
      	3.  Check for unboxed tuples in function args
      1. Tidy up PredTypes
      The main thing in this commit is to modify the representation of Types
      so that they are a (much) better for the qualified-type world.  This
      should simplify Jeff's life as he proceeds with implicit parameters
      and functional dependencies.  In particular, PredType, introduced by
      Jeff, is now blessed and dignified with a place in TypeRep.lhs:
      	data PredType  = Class  Class [Type]
      		       | IParam Name  Type
      Consider these examples:
      	f :: (Eq a) => a -> Int
      	g :: (?x :: Int -> Int) => a -> Int
      	h :: (r\l) => {r} => {l::Int | r}
      Here the "Eq a" and "?x :: Int -> Int" and "r\l" are all called
      *predicates*, and are represented by a PredType.  (We don't support
      TREX records yet, but the setup is designed to expand to allow them.)
      In addition, Type gains an extra constructor:
      	data Type = .... | PredTy PredType
      so that PredType is injected directly into Type.  So the type
      	p => t
      is represented by
      	PredType p `FunTy` t
      I have deleted the hackish IPNote stuff; predicates are dealt with entirely
      through PredTys, not through NoteTy at all.
      2.  Move Keys into PrelNames
      This is just a housekeeping operation. I've moved all the pre-assigned Uniques
      (aka Keys) from Unique.lhs into PrelNames.lhs.  I've also moved knowKeyRdrNames
      from PrelInfo down into PrelNames.  This localises in PrelNames lots of stuff
      about predefined names.  Previously one had to alter three files to add one,
      now only one.
      3.  Unboxed tuples
      Add a static check for unboxed tuple arguments.  E.g.
      	data T = T (# Int, Int #)
      is illegal
  20. 22 Sep, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-09-22 15:56:12 by simonpj] · 1bba522f
      simonpj authored
      	Tidying up HsLit, and making it possible to define
      		your own numeric library
      		Simon PJ 22 Sept 00
      ** NOTE: I did these changes on the aeroplane.  They should compile,
      	 and the Prelude still compiles OK, but it's entirely 
      	 possible that I've broken something
      The original reason for this many-file but rather shallow
      commit is that it's impossible in Haskell to write your own
      numeric library.  Why?  Because when you say '1' you get 
      (Prelude.fromInteger 1), regardless of what you hide from the
      Prelude, or import from other libraries you have written.  So the
      idea is to extend the -fno-implicit-prelude flag so that 
      in addition to no importing the Prelude, you can rebind 
      	fromInteger	-- Applied to literal constants
      	fromRational	-- Ditto
      	negate		-- Invoked by the syntax (-x)
      	the (-) used when desugaring n+k patterns
      After toying with other designs, I eventually settled on a simple,
      crude one: rather than adding a new flag, I just extended the
      semantics of -fno-implicit-prelude so that uses of fromInteger,
      fromRational and negate are all bound to "whatever is in scope" 
      rather than "the fixed Prelude functions".  So if you say
      	{-# OPTIONS -fno-implicit-prelude #-}
      	module M where
       	import MyPrelude( fromInteger )
      	x = 3
      the literal 3 will use whatever (unqualified) "fromInteger" is in scope,
      in this case the one gotten from MyPrelude.
      On the way, though, I studied how HsLit worked, and did a substantial tidy
      up, deleting quite a lot of code along the way.  In particular.
      * HsBasic.lhs is renamed HsLit.lhs.  It defines the HsLit type.
      * There are now two HsLit types, both defined in HsLit.
      	HsLit for non-overloaded literals (like 'x')
      	HsOverLit for overloaded literals (like 1 and 2.3)
      * HsOverLit completely replaces Inst.OverloadedLit, which disappears.
        An HsExpr can now be an HsOverLit as well as an HsLit.
      * HsOverLit carries the Name of the fromInteger/fromRational operation,
        so that the renamer can help with looking up the unqualified name 
        when -fno-implicit-prelude is on.  Ditto the HsExpr for negation.
        It's all very tidy now.
      * RdrHsSyn contains the stuff that handles -fno-implicit-prelude
        (see esp RdrHsSyn.prelQual).  RdrHsSyn also contains all the "smart constructors"
        used by the parser when building HsSyn.  See for example RdrHsSyn.mkNegApp
        (previously the renamer (!) did the business of turning (- 3#) into -3#).
      * I tidied up the handling of "special ids" in the parser.  There's much
        less duplication now.
      * Move Sven's Horner stuff to the desugarer, where it belongs.  
        There's now a nice function DsUtils.mkIntegerLit which brings together
        related code from no fewer than three separate places into one single
        place.  Nice!
      * A nice tidy-up in MatchLit.partitionEqnsByLit became possible.
      * Desugaring of HsLits is now much tidier (DsExpr.dsLit)
      * Some stuff to do with RdrNames is moved from ParseUtil.lhs to RdrHsSyn.lhs,
        which is where it really belongs.
      * I also removed 
      	many unnecessary imports from modules 
      	quite a bit of dead code
        in divers places
  21. 07 Sep, 2000 1 commit
  22. 17 Aug, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-08-17 16:28:44 by simonmar] · bb8442c9
      simonmar authored
      Replace a zipEqual with a zip in tcPat when checking a record pat.
      The former version caused a panic with DEBUG on if a record pattern
      was used with a non-record constructor.
  23. 14 Jul, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-07-14 08:17:36 by simonpj] · 77a8c0db
      simonpj authored
      This commit completely re-does the kind-inference mechanism.
      Previously it was inter-wound with type inference, but that was
      always hard to understand, and it finally broke when we started
      checking for ambiguity when type-checking a type signature (details
      So now kind inference is more clearly separated, so that it never
      takes place at the same time as type inference.  The biggest change
      is in TcTyClsDecls, which does the kind inference for a group of
      type and class declarations.  It now contains comments to explain
      how it all works.
      There are also comments in TypeRep which describes the slightly
      tricky way in which we deal with the fact that kind 'type' (written
      '*') actually has 'boxed type' and 'unboxed type' as sub-kinds.
      The whole thing is a bit of a hack, because we don't really have 
      sub-kinding, but it's less of a hack than before.
      A lot of general tidying up happened at the same time.
      In particular, I removed some dead code here and there
  24. 11 Jul, 2000 1 commit
  25. 25 May, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-05-25 12:41:14 by simonpj] · 495ef8bd
      simonpj authored
      		Apr/May 2000
      This is a pretty big commit!  It adds stuff I've been working on
      over the last month or so.  DO NOT MERGE IT WITH 4.07!
      Interface file formats have changed a little; you'll need
      to make clean before remaking.
      						Simon PJ
      Recompilation checking
      Substantial improvement in recompilation checking.  The version management
      is now entirely internal to GHC.  ghc-iface.lprl is dead!
      The trick is to generate the new interface file in two steps:
        - first convert Types etc to HsTypes etc, and thereby
      	build a new ParsedIface
        - then compare against the parsed (but not renamed) version of the old
      	interface file
      Doing this meant adding code to convert *to* HsSyn things, and to
      compare HsSyn things for equality.  That is the main tedious bit.
      Another improvement is that we now track version info for
      fixities and rules, which was missing before.
      Interface file reading
      Make interface files reading more robust.
        * If the old interface file is unreadable, don't fail. [bug fix]
        * If the old interface file mentions interfaces
          that are unreadable, don't fail. [bug fix]
        * When we can't find the interface file,
          print the directories we are looking in.  [feature]
      Type signatures
        * New flag -ddump-types to print type signatures
      Type pruning
      When importing
      	data T = T1 A | T2 B | T3 C
      it seems excessive to import the types A, B, C as well, unless
      the constructors T1, T2 etc are used.  A,B,C might be more types,
      and importing them may mean reading more interfaces, and so on.
       So the idea is that the renamer will just import the decl
      	data T
      unless one of the constructors is used.  This turns out to be quite
      easy to implement.  The downside is that we must make sure the
      constructors are always available if they are really needed, so
      I regard this as an experimental feature.
      Elimininate ThinAir names
      Eliminate ThinAir.lhs and all its works.  It was always a hack, and now
      the desugarer carries around an environment I think we can nuke ThinAir
      As part of this, I had to move all the Prelude RdrName defns from PrelInfo
      to PrelMods --- so I renamed PrelMods as PrelNames.
      I also had to move the builtinRules so that they are injected by the renamer
      (rather than appearing out of the blue in SimplCore).  This is if anything simpler.
      * Tidy up the data types involved in Rules
      * Eliminate RnEnv.better_provenance; use Name.hasBetterProv instead
      * Add Unique.hasKey :: Uniquable a => a -> Unique -> Bool
        It's useful in a lot of places
      * Fix a bug in interface file parsing for __U[!]
  26. 23 May, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-05-23 11:35:36 by simonpj] · bb91427f
      simonpj authored
      *** MERGE WITH 4.07 (once I've checked it works) ***
      * Fix result type signatures.  Note that a consequential change is that
        an ordinary binding with a variable on the left
      	f = e
        is now treated as a FunMonoBind, not a PatMonoBind.  This makes
        a few things a bit simpler (eg rnMethodBinds)
      * Fix warnings for unused imports.  This meant moving where provenances
        are improved in RnNames.  Move mkExportAvails from RnEnv to RnNames.
      * Print module names right (small change in Module.lhs and Rename.lhs)
      * Remove a few unused bindings
      * Add a little hack to let us print info about join points that turn
        out not to be let-no-escaped.  The idea is to call them "$j" and report
        any such variables that are not let-no-escaped.
      * Some small things aiming towards -ddump-types (harmless but incomplete)
  27. 13 Apr, 2000 1 commit
    • panne's avatar
      [project @ 2000-04-13 20:41:30 by panne] · f5262d44
      panne authored
      GHC has instance amnesia again, so a bunch of funny
      `import Ppr{Core,Type} ()? had to be added. Sorry,
      but I need a bootstrapping GHC.
  28. 27 Mar, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-03-27 16:22:09 by simonpj] · 783e505e
      simonpj authored
      Fix a bug in import listing in interface files that meant we lost track of
      interface files.  This fixes the problem that led Sven to add lots of
      import PprType() decls.  I've removed them all again!
  29. 25 Mar, 2000 1 commit
    • panne's avatar
      [project @ 2000-03-25 12:38:40 by panne] · cca2c69f
      panne authored
      Adding a bunch of `import PprType ()' to make 4.07 compile itself.
      Strangely enough, compilation with 4.06 worked without these, so
      this is probably only fighting the symptoms of something deeper,
      and somebody should have a look at it. But for now, I simply need
      a bootstrapping 4.07...
  30. 24 Mar, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-03-24 17:49:29 by simonpj] · 6c872fff
      simonpj authored
      a) Small wibbles to do with inlining and floating
      b) Implement Ralf's request, so that one can write
      	type F = forall a. a -> a
      	f :: Int -> F
      	f = ...
         The for-alls inside F are hoisted out to the top of
         the type signature for f.  This applies uniformly to
         all user-written types
  31. 23 Mar, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-03-23 17:45:17 by simonpj] · 111cee3f
      simonpj authored
      This utterly gigantic commit is what I've been up to in background
      mode in the last couple of months.  Originally the main goal
      was to get rid of Con (staturated constant applications)
      in the CoreExpr type, but one thing led to another, and I kept
      postponing actually committing.   Sorry.
      	Simon, 23 March 2000
      I've tested it pretty thoroughly, but doubtless things will break.
      Here are the highlights
      * Con is gone; the CoreExpr type is simpler
      * NoRepLits have gone
      * Better usage info in interface files => less recompilation
      * Result type signatures work
      * CCall primop is tidied up
      * Constant folding now done by Rules
      * Lots of hackery in the simplifier
      * Improvements in CPR and strictness analysis
      Many bug fixes including
      * Sergey's DoCon compiles OK; no loop in the strictness analyser
      * Volker Wysk's programs don't crash the CPR analyser
      I have not done much on measuring compilation times and binary sizes;
      they could have got worse.  I think performance has got significantly
      better, though, in most cases.
      Removing the Con form of Core expressions
      The big thing is that
        For every constructor C there are now *two* Ids:
      	C is the constructor's *wrapper*. It evaluates and unboxes arguments
      	before calling $wC.  It has a perfectly ordinary top-level defn
      	in the module defining the data type.
      	$wC is the constructor's *worker*.  It is like a primop that simply
      	allocates and builds the constructor value.  Its arguments are the
      	actual representation arguments of the constructor.
      	Its type may be different to C, because:
      		- useless dict args are dropped
      		- strict args may be flattened
        For every primop P there is *one* Id, its (curried) Id
        Neither contructor worker Id nor the primop Id have a defminition anywhere.
        Instead they are saturated during the core-to-STG pass, and the code generator
        generates code for them directly. The STG language still has saturated
        primops and constructor applications.
      * The Const type disappears, along with Const.lhs.  The literal part
        of Const.lhs reappears as Literal.lhs.  Much tidying up in here,
        to bring all the range checking into this one module.
      * I got rid of NoRep literals entirely.  They just seem to be too much trouble.
      * Because Con's don't exist any more, the funny C { args } syntax
        disappears from inteface files.
      * Result type signatures now work
      	f :: Int -> Int = \x -> x
      	-- The Int->Int is the type of f
      	g x y :: Int = x+y
      	-- The Int is the type of the result of (g x y)
      Recompilation checking and make
      * The .hi file for a modules is not touched if it doesn't change.  (It used to
        be touched regardless, forcing a chain of recompilations.)  The penalty for this
        is that we record exported things just as if they were mentioned in the body of
        the module.  And the penalty for that is that we may recompile a module when
        the only things that have changed are the things it is passing on without using.
        But it seems like a good trade.
      * -recomp is on by default
      Foreign declarations
      * If you say
      	foreign export zoo :: Int -> IO Int
        then you get a C produre called 'zoo', not 'zzoo' as before.
        I've also added a check that complains if you export (or import) a C
        procedure whose name isn't legal C.
      Code generation and labels
      * Now that constructor workers and wrappers have distinct names, there's
        no need to have a Foo_static_closure and a Foo_closure for constructor Foo.
        I nuked the entire StaticClosure story.  This has effects in some of
        the RTS headers (i.e. s/static_closure/closure/g)
      Rules, constant folding
      * Constant folding becomes just another rewrite rule, attached to the Id for the
        PrimOp.   To achieve this, there's a new form of Rule, a BuiltinRule (see CoreSyn.lhs).
        The prelude rules are in prelude/PrelRules.lhs, while simplCore/ConFold.lhs has gone.
      * Appending of constant strings now works, using fold/build fusion, plus
        the rewrite rule
      	unpack "foo" c (unpack "baz" c n)  =  unpack "foobaz" c n
        Implemented in PrelRules.lhs
      * The CCall primop is tidied up quite a bit.  There is now a data type CCall,
        defined in PrimOp, that packages up the info needed for a particular CCall.
        There is a new Id for each new ccall, with an big "occurrence name"
      	{__ccall "foo" gc Int# -> Int#}
        In interface files, this is parsed as a single Id, which is what it is, really.
      * There were numerous places where the host compiler's
        minInt/maxInt was being used as the target machine's minInt/maxInt.
        I nuked all of these; everything is localised to inIntRange and inWordRange,
        in Literal.lhs
      * Desugaring record updates was broken: it didn't generate correct matches when
        used withe records with fancy unboxing etc.  It now uses matchWrapper.
      * Significant tidying up in codeGen/SMRep.lhs
      * Add __word, __word64, __int64 terminals to signal the obvious types
        in interface files.  Add the ability to print word values in hex into
        C code.
      * PrimOp.lhs is no longer part of a loop.  Remove PrimOp.hi-boot*
      * isProductTyCon no longer returns False for recursive products, nor
        for unboxed products; you have to test for these separately.
        There's no reason not to do CPR for recursive product types, for example.
        Ditto splitProductType_maybe.
      * New -fno-case-of-case flag for the simplifier.  We use this in the first run
        of the simplifier, where it helps to stop messing up expressions that
        the (subsequent) full laziness pass would otherwise find float out.
        It's much more effective than previous half-baked hacks in inlining.
        Actually, it turned out that there were three places in Simplify.lhs that
        needed to know use this flag.
      * Make the float-in pass push duplicatable bindings into the branches of
        a case expression, in the hope that we never have to allocate them.
        (see FloatIn.sepBindsByDropPoint)
      * Arrange that top-level bottoming Ids get a NOINLINE pragma
        This reduced gratuitous inlining of error messages.
        But arrange that such things still get w/w'd.
      * Arrange that a strict argument position is regarded as an 'interesting'
        context, so that if we see
      	foldr k z (g x)
        then we'll be inclined to inline g; this can expose a build.
      * There was a missing case in CoreUtils.exprEtaExpandArity that meant
        we were missing some obvious cases for eta expansion
        Also improve the code when handling applications.
      * Make record selectors (identifiable by their IdFlavour) into "cheap" operations.
      	  [The change is a 2-liner in CoreUtils.exprIsCheap]
        This means that record selection may be inlined into function bodies, which
        greatly improves the arities of overloaded functions.
      * Make a cleaner job of inlining "lone variables".  There was some distributed
        cunning, but I've centralised it all now in SimplUtils.analyseCont, which
        analyses the context of a call to decide whether it is "interesting".
      * Don't specialise very small functions in Specialise.specDefn
        It's better to inline it.  Rather like the worker/wrapper case.
      * Be just a little more aggressive when floating out of let rhss.
        See comments with Simplify.wantToExpose
        A small change with an occasional big effect.
      * Make the inline-size computation think that
      	case x of I# x -> ...
        is *free*.
      CPR analysis
      * Fix what was essentially a bug in CPR analysis.  Consider
      	letrec f x = let g y = let ... in f e1
      		     if ... then (a,b) else g x
        g has the CPR property if f does; so when generating the final annotated
        RHS for f, we must use an envt in which f is bound to its final abstract
        value.  This wasn't happening.  Instead, f was given the CPR tag but g
        wasn't; but of course the w/w pass gives rotten results in that case!!
        (Because f's CPR-ness relied on g's.)
        On they way I tidied up the code in CprAnalyse.  It's quite a bit shorter.
        The fact that some data constructors return a constructed product shows
        up in their CPR info (MkId.mkDataConId) not in CprAnalyse.lhs
      Strictness analysis and worker/wrapper
      * BIG THING: pass in the demand to StrictAnal.saExpr.  This affects situations
      	f (let x = e1 in (x,x))
        where f turns out to have strictness u(SS), say.  In this case we can
        mark x as demanded, and use a case expression for it.
        The situation before is that we didn't "know" that there is the u(SS)
        demand on the argument, so we simply computed that the body of the let
        expression is lazy in x, and marked x as lazily-demanded.  Then even after
        f was w/w'd we got
      	let x = e1 in case (x,x) of (a,b) -> $wf a b
        and hence
      	let x = e1 in $wf a b
        I found a much more complicated situation in spectral/sphere/Main.shade,
        which improved quite a bit with this change.
      * Moved the StrictnessInfo type from IdInfo to Demand.  It's the logical
        place for it, and helps avoid module loops
      * Do worker/wrapper for coerces even if the arity is zero.  Thus:
      	stdout = coerce Handle (..blurg..)
      	wibble = (...blurg...)
      	stdout = coerce Handle wibble
        This is good because I found places where we were saying
      	case coerce t stdout of { MVar a ->
      	case coerce t stdout of { MVar b ->
        and the redundant case wasn't getting eliminated because of the coerce.
  32. 28 Jan, 2000 1 commit
    • lewie's avatar
      [project @ 2000-01-28 20:52:37 by lewie] · 266fadd9
      lewie authored
      First pass at implicit parameters.  Honest, I didn't really go in *intending*
      to modify every file in the typechecker... ;-)  The breadth of the change
      is partly due to generalizing contexts so that they are not hardwired to
      be (Class, [Type]) pairs.  See types/Type.lhs for details (look for PredType).
  33. 06 Dec, 1999 1 commit
    • lewie's avatar
      [project @ 1999-12-06 22:52:26 by lewie] · e03c0dd3
      lewie authored
      Fixed a FunDep leak in tcSimplifyToDicts (they weren't being filtered out),
      and fixed bug in instance improvement (matching wasn't being done correctly
      for polymorphic instances).
  34. 09 Nov, 1999 1 commit
  35. 08 Nov, 1999 1 commit
  36. 20 Aug, 1999 1 commit
  37. 01 Jun, 1999 1 commit
    • simonmar's avatar
      [project @ 1999-06-01 16:40:41 by simonmar] · 904f158f
      simonmar authored
      This commit replaces the old yacc parser with a Happy-generated one.
      	- The generated .hs file is *big*.  Best to use a recent
      	  version of Happy, and even better to add the -c flag
      	  to use unsafeCoerce# with ghc (versions 4.02+ please).
      	- The lexer has grown all sorts of unsightly growths and
      	  should be put down as soon as possible.
      	- Parse errors may result in strange diagnostics.  I'm looking
      	  into this.
      	- HsSyn now contains a few extra constructors due to the way
      	  patterns are parsed as expressions in the parser.
      	- The layout rule is implemented according to the Haskell
      	  report.  I found a couple of places in the libraries where
      	  we previously weren't adhering to this - in particular the
      	  rule about "nested contexts must be more indented than
      	  outer contexts".  The rule is necessary to disambiguate
      	  in the presence of empty declaration lists.
  38. 18 May, 1999 1 commit
  39. 27 Jan, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-01-27 14:51:14 by simonpj] · 18976e61
      simonpj authored
      Finally!  This commits the ongoing saga of Simon's hygiene sweep
      a) The 'unused variable' warnings from the renamer work.  
      b) Better error messages here and there, esp type checker
      c) Fixities for Haskell 98 (maybe I'd done that before)
      d) Lazy reporting of name clashes for Haskell 98 (ditto)
      a) type OccName has its own module.  OccNames are represented
         by a single FastString, not three as in the last round.  This
         string is held in Z-encoded form; a decoding function decodes
         for printing in user error messages.  There's a nice tight
         encoding for (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
      b) type Module is a proper ADT, in module OccName
      c) type RdrName is a proper ADT, in its own module
      d) type Name has a new, somwhat tidier, representation
      e) much grunting in the renamer to get Provenances right.
         This makes error messages look better (no spurious qualifiers)
  40. 18 Dec, 1998 1 commit
    • simonpj's avatar
      [project @ 1998-12-18 17:40:31 by simonpj] · 7e602b0a
      simonpj authored
      Another big commit from Simon.  Actually, the last one
      didn't all go into the main trunk; because of a CVS glitch it
      ended up in the wrong branch.
      So this commit includes:
      * Scoped type variables
      * Warnings for unused variables should work now (they didn't before)
      * Simplifier improvements:
      	- Much better treatment of strict arguments
      	- Better treatment of bottoming Ids
      	- No need for w/w split for fns that are merely strict
      	- Fewer iterations needed, I hope
      * Less gratuitous renaming in interface files and abs C
      * OccName is a separate module, and is an abstract data type
      I think the whole Prelude and Exts libraries compile correctly.
      Something isn't quite right about typechecking existentials though.