1. 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
  2. 18 Jul, 2000 2 commits
    • simonpj's avatar
      [project @ 2000-07-18 14:50:32 by simonpj] · 798374a5
      simonpj authored
      Arrange that type signatures that have no "parent" signatures
      work right.  For example
      
      	   module A
      	      f :: Int -> Int
      
      The panic in RnEnv.lookupBndrRn becomes an error message.  Also
      RnBinds.rnTopMonoBinds and rnMonoBinds were wrongly ignoring all
      signatures altogether if there were no bindings!
      798374a5
    • simonpj's avatar
      [project @ 2000-07-18 08:08:35 by simonpj] · bd0ff2bb
      simonpj authored
      Remove dead code: checkConstraints and univErr
      bd0ff2bb
  3. 14 Jul, 2000 2 commits
    • simonpj's avatar
      [project @ 2000-07-14 13:38:39 by simonpj] · 6a562dd5
      simonpj authored
      Arrange that type signatures work right.  Consider:
      
      	   module A
      		import M( f )
      		f :: Int -> Int
      		f x = x
      
      Here, the 'f' in the signature isn't ambiguous; it
      refers to the locally defined f.  (This isn't clear in
      the Haskell 98 report, but it will be.)
      6a562dd5
    • 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
  4. 11 Jul, 2000 1 commit
  5. 07 Jul, 2000 2 commits
  6. 06 Jul, 2000 2 commits
    • simonpj's avatar
      [project @ 2000-07-06 16:31:45 by simonpj] · 525898a9
      simonpj authored
      * Improve the warning "M is imported but nothing from it is used"
        In particular, don't warn if some instances from it are imported.
      
        It's pretty much impossible to do the Right Thing always.
        A comment in Rename.lhs says
      	-- NOTE: Consider
      	--	      module This
      	--		import M ()
      	--
      	--	 The import M() is not *necessarily* redundant, even if
      	-- 	 we suck in no instance decls from M (e.g. it contains
      	--	 no instance decls, or This contains no code).  It may be
      	--	 that we import M solely to ensure that M's orphan instance
      	--	 decls (or those in its imports) are visible to people who
      	--	 import This.  Sigh.
      	--	 There's really no good way to detect this, so the error message
      	--	 in RnEnv.warnUnusedModules is weakened instead
      
      * Minor comment changes to RnIfaces.lhs
      
      * Use NameEnv instead of UFM in TcEnv (tidy up only)
      525898a9
    • simonmar's avatar
      [project @ 2000-07-06 14:08:31 by simonmar] · 5d42ac16
      simonmar authored
      New form of literal: MachLabel, for addresses of labels.  Used by
      foreign label instead of MachLitLit now.
      
      Real lit-lits now cause the NCG to panic.
      
      Also: removed CLitLit from AbsCSyn; it was only used in one place for
      a purpose it shouldn't have been used for in the first place.
      5d42ac16
  7. 03 Jul, 2000 1 commit
    • panne's avatar
      [project @ 2000-07-03 19:48:07 by panne] · 180097ce
      panne authored
      Putting parentheses around expressions involving a mixture of
      multiplicative and additive operators might sometimes be a cunning
      idea...   :-}   Otherwise
         (591125662431::Int) `div` (517::Int)
      is correctly converted into
         (567659506 + (275 * 2147483647)) `div`  517
      but
          591125662431       `div` (517::Int)
      turns into the messed up
          567659506 + ((275 * 2147483647) `div`  517)
      180097ce
  8. 02 Jul, 2000 1 commit
    • panne's avatar
      [project @ 2000-07-02 18:59:10 by panne] · 2a0ffd1c
      panne authored
      Don't use addr2Integer for large integral literals anymore, use a
      Horner schema with numbers in the Int range instead. This improves
      constant folding, so e.g.  (0x87654321 :: Word32) is evaluated at
      compile time now. In theory we can completely say Good-bye to
      addr2Integer, but for the time being it's still there. Feel free to
      nuke it...  >:-)
      2a0ffd1c
  9. 22 Jun, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-06-22 14:41:29 by simonpj] · fad3991b
      simonpj authored
      *** MERGE WITH 4.07 ***
      
      * ParseIface.y should reject newtypes with no
        definition:
      	newtype T a ;
        The rest of the compiler falls over if it sees such a thing.
      fad3991b
  10. 09 Jun, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-06-09 15:53:12 by simonpj] · b610eca3
      simonpj authored
      GHC gets upset if you have types like
      
      	Eq a => a->a
      
      where 'a' is *not* universally quantified.
      By "upset" I mean that the typechecker generates
      rather bogus code, that subsequently kills Lint.
      
      Such types used to be rejected in the renamer,
      but Jeff removed that in favour of an ambiguity
      check in TcMonoType.  I remember agreeing to move
      the renamer check to the type checker, and Jeff did this,
      but the check in TcMonoType was only checking for
      *ambiguity*, which isn't quite the same.
      
      I've restored the missing check and commented it
      better in TcMonoType.
      
      Jeff: if this isn't right for you, let's dicuss.
      
      Incidentally, I also generalise the ambiguity check
      to detect
      	forall a. ?x::a => Int
      which is ambiguous.
      
      I did a few formatting changes too.
      b610eca3
  11. 31 May, 2000 1 commit
    • lewie's avatar
      [project @ 2000-05-31 10:13:57 by lewie] · e7f04a0d
      lewie authored
      Cleanup pass on functional dependencies.  Most noticeably, make it so that
      signatures involving classes with functional dependencies work.  Also,
      Fundeps are now properly handled by the simplifier, resolving problems
      where the fundeps were sometimes being discarded too early, and sometimes
      hanging around too long.  Took out the early ambiguity testing in the
      renamer, because that's too early (you don't know the fundeps yet).  Now,
      the ambiguity test happens in the typechecker.
      Functional Dependencies should now be up to snuff with Mark's paper,
      however, the derived instances and superclass extensions found in hugs
      are still not in there.
      It would be nice if this were merged into 4.07.  I have diffs against
      the 4.07 tree in case it's too thorny working around Simon's big commit.
      e7f04a0d
  12. 30 May, 2000 1 commit
  13. 29 May, 2000 1 commit
  14. 25 May, 2000 2 commits
    • 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
    • simonmar's avatar
      [project @ 2000-05-25 10:40:39 by simonmar] · b5c71bff
      simonmar authored
      Add missing case in parsing of inline pragmas.
      b5c71bff
  15. 24 May, 2000 3 commits
  16. 23 May, 2000 2 commits
    • simonmar's avatar
      [project @ 2000-05-23 15:59:25 by simonmar] · 16873c64
      simonmar authored
      Don't use commas in an SLIT("..")
      16873c64
    • 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)
      bb91427f
  17. 22 May, 2000 1 commit
  18. 10 May, 2000 1 commit
  19. 09 May, 2000 1 commit
  20. 08 May, 2000 2 commits
    • simonpj's avatar
      [project @ 2000-05-08 08:23:08 by simonpj] · 09845f43
      simonpj authored
      Name qualification
      ~~~~~~~~~~~~~~~~~~
      Yet another wilbble on the recent renamer fix, this
      time to make sure that names are printed unqualified
      if they should be.    Sigh.
      09845f43
    • simonpj's avatar
      [project @ 2000-05-08 07:14:35 by simonpj] · cf58efc1
      simonpj authored
      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]
      cf58efc1
  21. 29 Apr, 2000 1 commit
  22. 28 Apr, 2000 1 commit
  23. 13 Apr, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-04-13 11:56:35 by simonpj] · 9579283c
      simonpj authored
      Add support for 'packages'.
      
      * A package is a group of modules.
      
      * A package has a name (e.g. std)
      
      * A package is built into a single library (Unix; e.g. libHSstd.a)
                             or a single DLL     (Windows; e.g. HSstd.dll)
      
      * The '-package-name foo' flag tells GHC that the module being compiled
        is destined for package foo.
      
      * The '-package foo' flag tells GHC to make available modules
        from package 'foo'.  It replaces '-syslib foo' which is now deprecated.
      
      * Cross-package references cost an extra indirection in Windows,
        but not Unix
      
      * GHC does not maintain detailed cross-package dependency information.
        It does remember which modules in other packages the current module
        depends on, but not which things within those imported things.
      
      
      All of this tidies up the Prelude enormously.  The Prelude and
      Standard Libraries are built into a singl package called 'std'.  (This
      is a change; the library is now called libHSstd.a instead of libHS.a)
      9579283c
  24. 07 Apr, 2000 2 commits
    • simonpj's avatar
      [project @ 2000-04-07 15:24:15 by simonpj] · 5f990952
      simonpj authored
      * Make it so that interface files track dependencies on
        all modules except Prelude modules.
        (Was "library" modules, distinguished by a gross hack
         but that messed up StgHugs.)
      5f990952
    • simonpj's avatar
      [project @ 2000-04-07 13:45:46 by simonpj] · cfbedcec
      simonpj authored
      * Fix 'foreign export' and 'foreign export dynamic' so
        that we can export pure (non-IO) functions as well as IO-ish ones
      
        NB: There's a change to PrelIOBase, so you'll
            need to recompile the Prelude
      
      * Add Type.mkDictTys and call it in various places.
      cfbedcec
  25. 05 Apr, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-04-05 16:25:51 by simonpj] · d4e0a55c
      simonpj authored
      * Add new flag -fddump-minimal-imports, which dumps a file
        M.imports that contains the (allegedly) minimal bunch of
        imports that make the system work.
        It's done by Rename.printMinimalImports
      
      * Extend foreign import/export to handle
      	* Booleans
      	* newtypes
        as requested by the FFI team
      
      * Tidy up DsCCall quite a bit
        Remove maybeBoxedPrimTy from TcHsSyn
      d4e0a55c
  26. 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
  27. 30 Mar, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-03-30 16:23:56 by simonpj] · b822aa0e
      simonpj authored
      * Remove the unnecessary CPR parameter to mkUnfolding and friends
      
      * Make sure that even trivial wrappers have a __inline__
        (this was causing lots of 'substWorker' DEBUG messages)
      
      * Nuke demand info when the unfolding is a value
        (see notes with IdInfo.setUnfoldingInfo)
      
      * Add an update-in-place test to the 'interesting context'
        predicate in SimplUtils.
      b822aa0e
  28. 27 Mar, 2000 3 commits