1. 20 Nov, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-11-20 14:48:52 by simonpj] · c271b647
      simonpj authored
      When renaming, typechecking an expression from the user
      interface, we may suck in declarations from interface
      files (e.g. the Prelude).  This commit takes account of that.
      
      To do so, I did some significant restructuring in TcModule,
      with consequential changes and tidy ups elsewhere in the type
      checker.  I think there should be fewer lines in total than before.
      c271b647
  2. 07 Nov, 2000 2 commits
  3. 30 Oct, 2000 1 commit
  4. 25 Oct, 2000 2 commits
  5. 24 Oct, 2000 2 commits
  6. 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
      710e2074
  7. 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
      1bba522f
  8. 14 Sep, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-09-14 13:46:39 by simonpj] · cae34044
      simonpj authored
      ---------------------------------------
      	Simon's tuning changes: early Sept 2000
      	---------------------------------------
      
      Library changes
      ~~~~~~~~~~~~~~~
      * Eta expand PrelShow.showLitChar.  It's impossible to compile this well,
        and it makes a big difference to some programs (e.g. gen_regexps)
      
      * Make PrelList.concat into a good producer (in the foldr/build sense)
      
      
      Flag changes
      ~~~~~~~~~~~~
      * Add -ddump-hi-diffs to print out changes in interface files.  Useful
        when watching what the compiler is doing
      
      * Add -funfolding-update-in-place to enable the experimental optimisation
        that makes the inliner a bit keener to inline if it's in the RHS of
        a thunk that might be updated in place.  Sometimes this is a bad idea
        (one example is in spectral/sphere; see notes in nofib/Simon-nofib-notes)
      
      
      Tuning things
      ~~~~~~~~~~~~~
      * Fix a bug in SetLevels.lvlMFE.  (change ctxt_lvl to dest_level)
        I don't think this has any performance effect, but it saves making
        a redundant let-binding that is later eliminated.
      
      * Desugar.dsProgram and DsForeign
        Glom together all the bindings into a single Rec.  Previously the
        bindings generated by 'foreign' declarations were not glommed together, but
        this led to an infelicity (i.e. poorer code than necessary) in the modules
        that actually declare Float and Double (explained a bit more in Desugar.dsProgram)
      
      * OccurAnal.shortMeOut and IdInfo.shortableIdInfo
        Don't do the occurrence analyser's shorting out stuff for things which
        have rules.  Comments near IdInfo.shortableIdInfo.
        This is deeply boring, and mainly to do with making rules work well.
        Maybe rules should have phases attached too....
      
      * CprAnalyse.addIdCprInfo
        Be a bit more willing to add CPR information to thunks;
        in particular, if the strictness analyser has just discovered that this
        is a strict let, then the let-to-case transform will happen, and CPR is fine.
        This made a big difference to PrelBase.modInt, which had something like
      	modInt = \ x -> let r = ... -> I# v in
      			...body strict in r...
        r's RHS isn't a value yet; but modInt returns r in various branches, so
        if r doesn't have the CPR property then neither does modInt
      
      * MkId.mkDataConWrapId
        Arrange that vanilla constructors, like (:) and I#, get unfoldings that are
        just a simple variable $w:, $wI#.  This ensures they'll be inlined even into
        rules etc, which makes matching a bit more reliable.  The downside is that in
        situations like (map (:) xs), we'll end up with (map (\y ys. $w: y ys) xs.
        Which is tiresome but it doesn't happen much.
      
      * SaAbsInt.findStrictness
        Deal with the case where a thing with no arguments is bottom.  This is Good.
        E.g.   module M where { foo = error "help" }
        Suppose we have in another module
      	case M.foo of ...
        Then we'd like to do the case-of-error transform, without inlining foo.
      
      
      Tidying up things
      ~~~~~~~~~~~~~~~~~
      * Reorganised Simplify.completeBinding (again).
      
      * Removed the is_bot field in CoreUnfolding (is_cheap is true if is_bot is!)
        This is just a tidy up
      
      * HsDecls and others
        Remove the NewCon constructor from ConDecl.  It just added code, and nothing else.
        And it led to a bug in MkIface, which though that a newtype decl was always changing!
      
      * IdInfo and many others
        Remove all vestiges of UpdateInfo (hasn't been used for years)
      cae34044
  9. 01 Aug, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-08-01 09:08:25 by simonpj] · fe69f3c1
      simonpj authored
      Simon's Marktoberdorf Commits
      
      1.  Tidy up the renaming story for "system binders", such as
      dictionary functions, default methods, constructor workers etc.  These
      are now documented in HsDecls.  The main effect of the change, apart
      from tidying up, is to make the *type-checker* (instead of the
      renamer) generate names for dict-funs and default-methods.  This is
      good because Sergei's generic-class stuff generates new classes at
      typecheck time.
      
      
      2.  Fix the CSE pass so it does not require the no-shadowing invariant.
      Keith discovered that the simplifier occasionally returns a result
      with shadowing.  After much fiddling around (which has improved the
      code in the simplifier a bit) I found that it is nearly impossible to
      arrange that it really does do no-shadowing.  So I gave up and fixed
      the CSE pass (which is the only one to rely on it) instead.
      
      
      3. Fix a performance bug in the simplifier.  The change is in
      SimplUtils.interestingArg.  It computes whether an argment should 
      be considered "interesting"; if a function is applied to an interesting
      argument, we are more likely to inline that function.
      Consider this case
      	let x = 3 in f x
      The 'x' argument was considered "uninteresting" for a silly reason.
      Since x only occurs once, it was unconditionally substituted, but
      interestingArg didn't take account of that case.  Now it does.
      
      I also made interestingArg a bit more liberal.  Let's see if we
      get too much inlining now.
      
      
      4.  In the occurrence analyser, we were choosing a bad loop breaker.
      Here's the comment that's now in OccurAnal.reOrderRec
      
          score ((bndr, rhs), _, _)
      	| exprIsTrivial rhs 	   = 3	-- Practically certain to be inlined
      		-- Used to have also: && not (isExportedId bndr)
      		-- But I found this sometimes cost an extra iteration when we have
      		--	rec { d = (a,b); a = ...df...; b = ...df...; df = d }
      		-- where df is the exported dictionary. Then df makes a really
      		-- bad choice for loop breaker
      
      I also increased the score for bindings with a non-functional type, so that
      dictionaries have a better chance of getting inlined early
      
      
      5. Add a hash code to the InScopeSet (and make it properly abstract)
      This should make uniqAway a lot more robust.  Simple experiments suggest
      that uniqAway no longer gets into the long iteration chains that it used
      to.
      
      
      6.  Fix a bug in the inliner that made the simplifier tend to get into
      a loop where it would keep iterating ("4 iterations, bailing out" message).
      In SimplUtils.mkRhsTyLam we float bindings out past a big lambda, thus:
      	x = /\ b -> let g = \x -> f x x
      		    in E
      becomes
      	g* = /\a -> \x -> f x x
      	x = /\ b -> let g = g* b in E
      	
      It's essential that we don't simply inling g* back into the RHS of g,
      else we will be back to square 1.  The inliner is meant not to do this
      because there's no benefit to the inlining, but the size calculation
      was a little off in CoreUnfold.
      
      
      7.  In SetLevels we were bogus-ly building a Subst with an empty in-scope
      set, so a WARNING popped up when compiling some modules.  (knights/ChessSetList
      was the example that tickled it.)  Now in fact the warning wasn't an error,
      but the Right Thing to do is to carry down a proper Subst in SetLevels, so
      that is what I have now done.  It is very little more expensive.
      fe69f3c1
  10. 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
      irrelevant).
      
      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
      77a8c0db
  11. 11 Jul, 2000 1 commit
  12. 28 Jun, 2000 1 commit
  13. 18 Jun, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-06-18 08:37:17 by simonpj] · 91ef36b9
      simonpj authored
      *** MERGE WITH 4.07 ***
      
      * Fix the ambiguity check in TcMonotype.lhs so that
        it is not carried out for types read from interface 
        files.  Some workers may get ambiguous types but that
        does not matter, and should not make compilation fail.
        More detail in the comments with TcMonoType.tc_type_kind
        (the HsForAll case)
      
      * Don't create specialisations for type applications 
        where there's a matching rule.  The rule should
        clearly take precedence.  (Bug reported by Sven.)
        I havn't tested this fix.
      
      * Run the occurrence analyser after tidyCore, so that
        occurrence info (notably dead-var info) is correct
        for the code generators.  This should fix Erik's problem,
        but again I've not tested the fix.  The extra call 
        is in Main.lhs
      
      * Fix CoreToStg so that it can handle an StgLam in mkStgCase.
        This only shows up in a wierd case, documented in 
        CoreToStg.mkStgCase
      91ef36b9
  14. 16 Jun, 2000 1 commit
  15. 14 Jun, 2000 1 commit
  16. 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
      altogether.
      
      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.
      
      Miscellaneous
      ~~~~~~~~~~~~~
      * 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[!]
      495ef8bd
  17. 13 May, 2000 1 commit
    • lewie's avatar
      [project @ 2000-05-13 00:20:57 by lewie] · 6f122ef3
      lewie authored
      A clean-up pass on fundeps and implicit params.  Haven't yet incorporated
      changes from Hugs/GHC meeting yet, tho.
        - Fixed up several places in Type.lhs where IPNotes were probably being
          incorrectly handled.  Strongly suggests a better solution should be
          implemented for marking implicit params than piggybacking on NoteTys.
        - tcSimplifyAndCheck was handling implicit params incorrectly
          (holding on to them when it should have been booting them out to frees).
        - Improved improvement WRT type signatures (the signature is now taken
          into account when improving).
        - Added improvement when matching against local polymorphic types.
      6f122ef3
  18. 03 Apr, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-04-03 09:52:28 by simonpj] · e4b0fab5
      simonpj authored
      * Make it so that recursive newtype declarations don't send
        GHC into an infinite loop.
      
      	newtype T = MkT T
      
        This happened because Type.repType looked throught newtypes,
        and that never stopped!  Now TcTyDecls.mkNewTyConRep does the job
        more carefully, and the result is cached in the TyCon itself.
      
      
      * Improve the handling of type signatures & pragmas.  Previously a
        mis-placed (say) SPECIALISE instance pragmas could be silently
        ignored.
      
      
      Both these changes involved moving quite a lot of stuff between modules.
      e4b0fab5
  19. 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.
      
      
      Parsing
      ~~~~~~~
      * 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.
      
      Miscellaneous
      ~~~~~~~~~~~~~
      * 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*
      
      
      Types
      ~~~~~
      * 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.
      
      Simplification
      ~~~~~~~~~~~~~~~
      * 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
      		     in
      		     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
        like
      	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.
      111cee3f
  20. 16 Feb, 2000 1 commit
  21. 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).
      266fadd9
  22. 30 Nov, 1999 1 commit
    • lewie's avatar
      [project @ 1999-11-30 16:10:07 by lewie] · e1e1d020
      lewie authored
      First bits o' functional dependencies - just the syntax and related
      datatypes, plus started moving some of the static checks from the
      renamer (where we don't know about fundeps) to later in the typechecker.
      e1e1d020
  23. 18 May, 1999 1 commit
  24. 19 Apr, 1999 1 commit
    • simonm's avatar
      [project @ 1999-04-19 16:30:51 by simonm] · 791ce2a5
      simonm authored
      Allow a worker to be present for functions with no strictness info in
      an interface file.  This is useful for functions which get hit by CPR
      but not the strictness analyser.
      791ce2a5
  25. 13 Apr, 1999 1 commit
    • kglynn's avatar
      [project @ 1999-04-13 08:55:33 by kglynn] · 30b5b5cc
      kglynn authored
      (keving)
      
      Big Bang introduction of CPR Analysis Pass.  Note that now
      -fstrictness only does the strictness analysis phase,  it is necessary
      to follow this with -fworker-wrapper to actually do the required Core
      transformations. The -O option in the ghc driver script has been
      modified appropriately.
      
      For now,  CPR analysis is turned off.  To try it,  insert a
      -fcpr_analyse between the -fstrictness and the -fworker-wrapper
      options.
      
      Misc. comments:
      
      - The worker flag has been removed from an ID's StrictnessInfo field.
      Now the worker info is an extra field in the Id's prag info.
      
      - We do a nested CPR analysis,  but worker-wrapper only looks at the
      info for the outermost constructor,  else laziness can be lost.
      
      - Id's CPR Info in traces and interfaces file follows __M
      
      - Worker-wrappery transformation now accounts for both strictness and
      CPR analysis results.
      30b5b5cc
  26. 06 Apr, 1999 1 commit
  27. 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
      
      FUNCTIONALITY
      ~~~~~~~~~~~~~
      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)
      
      HYGIENE
      ~~~~~~~
      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)
      18976e61
  28. 14 Jan, 1999 1 commit
    • sof's avatar
      [project @ 1999-01-14 17:58:41 by sof] · 3160f854
      sof authored
      Assorted minor Haskell 98 changes:
      
        * Maximal munch rule for "--" comments
        * _ as lower-case letter, "_" is a reserved id. Prefixing unused
          variable names in patterns with '_' causes the renamer not to
          report such names as being unused.
        * allow empty decls
        * comprehensions are now list comprehensions, not monadic.
        * use Monad.fail to signal pattern matching errors within
          do expressions.
        * remove record punning.
        * empty contexts are now legal  (go wild!)
        * allow records with no fields
        * allow newtypes with a labelled field
        * default default is now (Integer, Double)
        * turn off defaulting mechanism for args & res to a _ccall_.
        * allow LHSs of the form  (a -.- b) x = ...
        * Main.main can now have type (IO a)
        * nuked Void (and its use in the compiler sources.)
        * deriving machinery for Enum now also generate 'succ' and 'pred'
          method bindings.
      3160f854
  29. 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.
      7e602b0a
  30. 02 Dec, 1998 1 commit
  31. 08 Nov, 1998 1 commit
  32. 14 Aug, 1998 1 commit
  33. 06 Apr, 1998 1 commit
  34. 19 Mar, 1998 1 commit
  35. 03 Feb, 1998 1 commit
    • simonm's avatar
      [project @ 1998-02-03 17:13:54 by simonm] · be33dbc9
      simonm authored
      - Fixes for bootstrapping with 3.01.
        - Use 'official' extension interfaces rather than internal prelude
          modules (such as ArrBase) where possible.
        - Remove some cruft.
        - Delete some unused imports found by '-fwarn-unused-imports'.
      be33dbc9
  36. 08 Jan, 1998 1 commit
    • simonm's avatar
      [project @ 1998-01-08 18:03:08 by simonm] · 9dd6e1c2
      simonm authored
      The Great Multi-Parameter Type Classes Merge.
      
      Notes from Simon (abridged):
      
      * Multi-parameter type classes are fully implemented.
      * Error messages from the type checker should be noticeably improved
      * Warnings for unused bindings (-fwarn-unused-names)
      * many other minor bug fixes.
      
      Internally there are the following changes
      
      * Removal of Haskell 1.2 compatibility.
      * Dramatic clean-up of the PprStyle stuff.
      * The type Type has been substantially changed.
      * The dictionary for each class is represented by a new
        data type for that purpose, rather than by a tuple.
      9dd6e1c2
  37. 24 Sep, 1997 1 commit