1. 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
  2. 04 Jan, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-01-04 17:40:46 by simonpj] · 5ca77490
      simonpj authored
      This commit arranges that literal strings will fuse
      nicely, by expressing them as an application of build.
      
      * NoRepStr is now completely redundant, though I havn't removed it yet.
      
      * The unpackStr stuff moves from PrelPack to PrelBase.
      
      * There's a new form of Rule, a BuiltinRule, for rules that
        can't be expressed in Haskell.  The string-fusion rule is one
        such.  It's defined in prelude/PrelRules.lhs.
      
      * PrelRules.lhs also contains a great deal of code that
        implements constant folding.  In due course this will replace
        ConFold.lhs, but for the moment it simply duplicates it.
      5ca77490
  3. 20 Dec, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-12-20 10:34:27 by simonpj] · e921b2e3
      simonpj authored
      This commit implements a substantial re-organisation of the Prelude
      It also fixes a couple of small renamer bugs that were reported recently
      	(notably, Sven pointed out that we weren't reporting
      	unused imports properly)
      
      My original goal was to get rid of all "orphan" modules (i.e. ones
      with instance decls that don't belong either to a tycon or a class
      defined in the same module).  This should reduce the number of
      interface files that have to be read when compiling small Haskell
      modules.
      
      But like most expeditions into the Prelude Swamp, it spiraled out
      of control.  The result is quite satisfactory, though.
      
      	GONE AWAY:	PrelCCall, PrelNumExtra
      
      	NEW:		PrelReal, PrelFloat, PrelByteArr, PrelNum.hi-boot
      
      (The extra PrelNum.hi-boot is because of a tiresome thin-air Id, addr2Integer,
      which used to be in PrelBase.)
      
      Quite a lot of types have moved from one module to another,
      which entails some changes to part of the compiler (PrelInfo, PrelMods) etc,
      and there are a few places in the RTS includes and even in the driver
      that know about these home modules (alas).
      
      So the rough structure is as follows, in (linearised) dependency order
      	[this list now appears in PrelBase.lhs]
      
      PrelGHC		Has no implementation.  It defines built-in things, and
      		by importing it you bring them into scope.
      		The source file is PrelGHC.hi-boot, which is just
      		copied to make PrelGHC.hi
      
      		Classes: CCallable, CReturnable
      
      PrelBase	Classes: Eq, Ord, Functor, Monad
      		Types:   list, (), Int, Bool, Ordering, Char, String
      
      PrelTup		Types: tuples, plus instances for PrelBase classes
      
      PrelShow	Class: Show, plus instances for PrelBase/PrelTup types
      
      PrelEnum	Class: Enum,  plus instances for PrelBase/PrelTup types
      
      PrelMaybe	Type: Maybe, plus instances for PrelBase classes
      
      PrelNum		Class: Num, plus instances for Int
      		Type:  Integer, plus instances for all classes so far (Eq, Ord, Num, Show)
      
      		Integer is needed here because it is mentioned in the signature
      		of 'fromInteger' in class Num
      
      PrelReal	Classes: Real, Integral, Fractional, RealFrac
      			 plus instances for Int, Integer
      		Types:  Ratio, Rational
      			plus intances for classes so far
      
      		Rational is needed here because it is mentioned in the signature
      		of 'toRational' in class Real
      
      Ix		Classes: Ix, plus instances for Int, Bool, Char, Integer, Ordering, tuples
      
      PrelArr		Types: Array, MutableArray, MutableVar
      
      		Does *not* contain any ByteArray stuff (see PrelByteArr)
      		Arrays are used by a function in PrelFloat
      
      PrelFloat	Classes: Floating, RealFloat
      		Types:   Float, Double, plus instances of all classes so far
      
      		This module contains everything to do with floating point.
      		It is a big module (900 lines)
      		With a bit of luck, many modules can be compiled without ever reading PrelFloat.hi
      
      PrelByteArr	Types: ByteArray, MutableByteArray
      
      		We want this one to be after PrelFloat, because it defines arrays
      		of unboxed floats.
      
      
      Other Prelude modules are much easier with fewer complex dependencies.
      e921b2e3
  4. 09 Dec, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-12-09 12:30:56 by simonpj] · 39262efa
      simonpj authored
      A bunch of small changes in the way that usage information
      is generated to stuff into interface files.  I'm not certain
      anything was really wrong before, but it's tidier now, and
      there are slightly fewer dependencies generated.  Main
      differences are in RnIfaces.getImportVersions
      
      I also made the check for orphan rules a bit cleverer
      (Rename.isOrphanDecl) so that we get fewer spurious orphan modules.
      
      Simon
      39262efa
  5. 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
  6. 29 Nov, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-11-29 17:34:14 by simonpj] · e1a4f2a5
      simonpj authored
      Make it so that a class decl generates default method decls
      for every method, not just for the ones that the user supplies
      default-methods for.
      
      GHC will never call these default-default methods, because
      when it finds an instance decl with no defn for a method,
      *and* the class decl doesn't have a user-programmed default
      method, it whips up a new default method for that instance
      decl so that the error message is more informative than
      the default-default method would be.
      
      But Hugs isn't so smart, and wants to call something from
      the class decl.
      
      This change required fiddling with more than I expected.  Sigh.
      
      Simon
      e1a4f2a5
  7. 01 Nov, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-11-01 17:09:54 by simonpj] · 30b5ebe4
      simonpj authored
      A regrettably-gigantic commit that puts in place what Simon PJ
      has been up to for the last month or so, on and off.
      
      The basic idea was to restore unfoldings to *occurrences* of
      variables without introducing a space leak.  I wanted to make
      sure things improved relative to 4.04, and that proved depressingly
      hard.  On the way I discovered several quite serious bugs in the
      simplifier.
      
      Here's a summary of what's gone on.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * No commas between for-alls in RULES.  This makes the for-alls have
        the same syntax as in types.
      
      * Arrange that simplConArgs works in one less pass than before.
        This exposed a bug: a bogus call to completeBeta.
      
      * Add a top-level flag in CoreUnfolding, used in callSiteInline
      
      * Extend w/w to use etaExpandArity, so it does eta/coerce expansion
      
      * Implement inline phases.   The meaning of the inline pragmas is
        described in CoreUnfold.lhs.  You can say things like
      	{#- INLINE 2 build #-}
        to mean "inline build in phase 2"
      
      * Don't float anything out of an INLINE.
        Don't float things to top level unless they also escape a value lambda.
      	[see comments with SetLevels.lvlMFE
        Without at least one of these changes, I found that
      	{-# INLINE concat #-}
      	concat = __inline (/\a -> foldr (++) [])
        was getting floated to
      	concat = __inline( /\a -> lvl a )
      	lvl = ...inlined version of foldr...
      
        Subsequently I found that not floating constants out of an INLINE
        gave really bad code like
      	__inline (let x = e in \y -> ...)
        so I now let things float out of INLINE
      
      * Implement the "reverse-mapping" idea for CSE; actually it turned out to be easier
        to implement it in SetLevels, and may benefit full laziness too.
      
      * It's a good idea to inline inRange. Consider
      
      	index (l,h) i = case inRange (l,h) i of
      		  	  True ->  l+i
      			  False -> error
        inRange itself isn't strict in h, but if it't inlined then 'index'
        *does* become strict in h.  Interesting!
      
      * Big change to the way unfoldings and occurrence info is propagated in the simplifier
        The plan is described in Subst.lhs with the Subst type
        Occurrence info is now in a separate IdInfo field than user pragmas
      
      * I found that
      	(coerce T (coerce S (\x.e))) y
        didn't simplify in one round. First we get to
      	(\x.e) y
        and only then do the beta. Solution: cancel the coerces in the continuation
      
      * Amazingly, CoreUnfold wasn't counting the cost of a function an application.
      
      * Disable rules in initial simplifier run.  Otherwise full laziness
        doesn't get a chance to lift out a MFE before a rule (e.g. fusion)
        zaps it.  queens is a case in point
      
      * Improve float-out stuff significantly.  The big change is that if we have
      
      	\x -> ... /\a -> ...let p = ..a.. in let q = ...p...
      
        where p's rhs doesn't x, we abstract a from p, so that we can get p past x.
        (We did that before.)  But we also substitute (p a) for p in q, and then
        we can do the same thing for q.  (We didn't do that, so q got stuck.)
        This is much better.  It involves doing a substitution "as we go" in SetLevels,
        though.
      30b5ebe4
  8. 17 Sep, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-09-17 09:15:22 by simonpj] · 731f53de
      simonpj authored
      This bunch of commits represents work in progress on inlining and
      worker/wrapper stuff.
      
      Currently, I think it makes the compiler slightly worse than 4.04, for
      reasons I don't yet understand.  But it means that Simon and I can
      both peer at what is going on.
      
      * Substantially improve handling of coerces in worker/wrapper
      
      * exprIsDupable for an application (f e1 .. en) wasn't calling exprIsDupable
        on the arguments!!  So applications with few, but large, args were being dupliated.
      
      * sizeExpr on an application wasn't doing a nukeScrutDiscount on the arg of
        an application!!  So bogus discounts could accumulate from arguments!
      
      * Improve handling of INLINE pragmas in calcUnfoldingGuidance.  It was really
        wrong before
      731f53de
  9. 15 Jul, 1999 1 commit
    • keithw's avatar
      [project @ 1999-07-15 14:08:03 by keithw] · 9d787ef5
      keithw authored
      This commit makes a start at implementing polymorphic usage
      annotations.
      
      * The module Type has now been split into TypeRep, containing the
        representation Type(..) and other information for `friends' only,
        and Type, providing the public interface to Type.  Due to a bug in
        the interface-file slurping prior to ghc-4.04, {-# SOURCE #-}
        dependencies must unfortunately still refer to TypeRep even though
        they are not friends.
      
      * Unfoldings in interface files now print as __U instead of __u.
        UpdateInfo now prints as __UA instead of __U.
      
      * A new sort of variables, UVar, in their own namespace, uvName, has
        been introduced for usage variables.
      
      * Usage binders __fuall uv have been introduced.  Usage annotations
        are now __u - ty (used once), __u ! ty (used possibly many times),
        __u uv ty (used uv times), where uv is a UVar.  __o and __m have
        gone.  All this still lives only in a TyNote, *for now* (but not for
        much longer).
      
      * Variance calculation for TyCons has moved from
        typecheck/TcTyClsDecls to types/Variance.
      
      * Usage annotation and inference are now done together in a single
        pass.  Provision has been made for inferring polymorphic usage
        annotations (with __fuall) but this has not yet been implemented.
        Watch this space!
      9d787ef5
  10. 14 Jul, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-07-14 14:40:20 by simonpj] · 4e7d56fd
      simonpj authored
      Main things:
      
      * Add splitProductType_maybe to DataCon.lhs, with type
        splitProductType_maybe
      	:: Type 			-- A product type, perhaps
      	-> Maybe (TyCon, 		-- The type constructor
      		  [Type],		-- Type args of the tycon
      		  DataCon,		-- The data constructor
      		  [Type])		-- Its *representation* arg types
      
        Then use it in many places (e.g. worker-wrapper places) instead
        of a pile of junk
      
      * Clean up various uses of dataConArgTys, which were plain wrong because
        they weren't passed the existential type arguments.  Most of these calls
        are eliminated by using splitProductType_maybe above.  I hope I correctly
        squashed the others. This fixes a bug that Meurig's programs showed up.
      
          module FailGHC (killSustainer) where
          import Weak
          import IOExts
      
          data Sustainer = forall a . Sustainer (IORef (Maybe a)) (IO ())
      
          killSustainer :: Sustainer -> IO ()
          killSustainer (Sustainer _ act) = act
      
        The above program used to kill the compiler.
      
      * A fairly concerted attack on the Dreaded Space Leak.
      	- Add Type.seqType, CoreSyn.seqExpr, CoreSyn.seqRules
      
      	- Add some seq'ing when building Ids and IdInfos
      		These reduce the space usage a lot
      
      	- Add CoreSyn.coreBindsSize, which is pretty strict in the program,
      		and call it when we have -dshow-passes.
      
      	- Do not put the inlining in an Id that is being plugged into
      		the result-expression of the simplifier.  This cures
      		a the 'wedge' in the space profile for reasons I don't understand fully
      
        Together, these things reduce the max space usage when compiling PrelNum from
        17M to about 7Mbytes.
      
        I think there are now *too many* seqs, and they waste work, but I don't have
        time to find which ones.
      
        Furthermore, we aren't done. For some reason, some of the stuff allocated by
        the simplifier makes it through all during code generation and I don't see why.
        There's a should-be-unnecessary call to coreBindsSize in Main.main which
        zaps some, but not all of this space.
      
        -dshow-passes reduces space usage a bit, but I don't think it should really.
      
        All the measurements were made on a compiler compiled with profiling by
        GHC 3.03.    I hope they carry over to other builds!
      
      * One trivial thing: changed all variables 'label' to 'lbl', becuase the
        former is a keyword with -fglagow-exts in GHC 3.03 (which I was compiling with).
        Something similar in StringBuffer.
      4e7d56fd
  11. 06 Jul, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-07-06 16:45:31 by simonpj] · 9d38678e
      simonpj authored
      All Simon's recent tuning changes.  Rough summary follows:
      
      * Fix Kevin Atkinson's cant-find-instance bug.  Turns out that Rename.slurpSourceRefs
        needs to repeatedly call getImportedInstDecls, and then go back to slurping
        source-refs.  Comments with Rename.slurpSourceRefs.
      
      * Add a case to Simplify.mkDupableAlt for the quite-common case where there's
        a very simple alternative, in which case there's no point in creating a
        join-point binding.
      
      * Fix CoreUtils.exprOkForSpeculation so that it returns True of (==# a# b#).
        This lack meant that
      	case ==# a# b# of { True -> x; False -> x }
        was not simplifying
      
      * Make float-out dump bindings at the top of a function argument, as
        at the top of a let(rec) rhs.  See notes with FloatOut.floatRhs
      
      * Make the ArgOf case of mkDupableAlt generate a OneShot lambda.
        This gave a noticeable boost to spectral/boyer2
      
      
      * Reduce the number of coerces, using worker/wrapper stuff.
        The main idea is in WwLib.mkWWcoerce.  The gloss is that we must do
        the w/w split even for small non-recursive things.  See notes with
        WorkWrap.tryWw.
      
      * This further complicated getWorkerId, so I finally bit the bullet and
        make the workerInfo field of the IdInfo work properly, including
        under substitutions.  Death to getWorkerId.  Kevin Glynn will be happy.
      
      * Make all lambdas over realWorldStatePrimTy
        into one-shot lambdas.  This is a GROSS HACK.
      
      * Also make the occurrence analyser aware of one-shot lambdas.
      
      * Make various Prelude things into INLINE, so that foldr doesn't
        get inlined in their body, so that the caller gets the benefit
        of fusion.  Notably in PrelArr.lhs.
      9d38678e
  12. 18 Jun, 1999 1 commit
  13. 18 May, 1999 1 commit
  14. 14 Apr, 1999 1 commit
    • kglynn's avatar
      [project @ 1999-04-14 04:07:57 by kglynn] · 27ce7270
      kglynn authored
      (keving)
      
      Sigh,  No point w/w pass storing the worker id in wrapper's info
      field,  because later simplifications may change the worker id. I've
      restored the original code which looks in the wrapper function and
      guesses the worker id.  With the addition of CPR transf. this looks a
      bit fragile. thinks, thinks, ....
      27ce7270
  15. 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
  16. 06 Apr, 1999 1 commit
  17. 02 Mar, 1999 1 commit
  18. 28 Jan, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-01-28 09:19:57 by simonpj] · b70e2f94
      simonpj authored
      Always inline nullary constructors.  This makes a 
      difference in:
      
      	case x ># y of r {
      	  True  -> f1 r
      	  False -> f2 r
       	}
      
      The code generator currently has difficulty binding "r"
      to the boolean result of the comparision (and the compiler
      crashes).  This fix substitutes for r, thus:
      
      	case x ># y of r {
      	  True  -> f1 True
      	  False -> f2 False
       	}
      
      Voila.
      b70e2f94
  19. 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
  20. 22 Dec, 1998 1 commit
    • simonpj's avatar
      [project @ 1998-12-22 16:31:28 by simonpj] · 8295d9ca
      simonpj authored
      1.  Add primOpStrictness to PrimOp.lhs, and use it in
      	- the strictness analyser
      	- the simplifier
          to deal correctly with PrimOps that are non-strict.
      
         ToDo: use this new facility to clean up SeqOp, ParOp.
      
      2. Fix the instance-decl-import bug, but printing de-synonym'd types
         in interface files.
      
      3. Make the simplifier treat applications with an unlifted-type arg
         in the same way it would if the function was strict
         (in rebuild_strict)
      8295d9ca
  21. 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
  22. 02 Dec, 1998 1 commit
  23. 14 Aug, 1998 1 commit
  24. 16 Jun, 1998 1 commit
    • sof's avatar
      [project @ 1998-06-16 12:25:36 by sof] · 1ca8c2c7
      sof authored
      New function: okToUnfoldInHiFile.
      
        - For values whose RHS have been deemed to be interface
          file unfolding candidates, do a last minute check to
          see whether the unfolding is really suitable.
      
          An unfolding is not suitable iff
      
             - contains a _casm_
             - contains a lit-lit
      
          The reason for not unfolding _casm_/lit-lits into
          interface files is that their C fragments are likely
          to mention #defines/functions that will be
          out-of-scope at an unfolding site. Turning off unfolding
          of such expressions avoid this unfortunate situation.
      1ca8c2c7
  25. 22 May, 1998 1 commit
    • simonm's avatar
      [project @ 1998-05-22 15:23:11 by simonm] · f36fb2ce
      simonm authored
      Add NOINLINE pragma.
      
      - add new type of inline info: IDontWantToBeINLINEd
      
      - hopefully get the interactions between IMustNotBeINLINEd (which is
        used by the simplifier to ensure termination when simplifying
        recursive binding groups) and IDontWantToBeINLINEd.
      
      - no need to pass NOINLINE across modules, we just make sure that any
        function marked as NOLINE doesn't get an unfolding in the interface.
      f36fb2ce
  26. 14 Apr, 1998 1 commit
  27. 08 Apr, 1998 1 commit
  28. 07 Apr, 1998 1 commit
  29. 19 Mar, 1998 2 commits
  30. 25 Feb, 1998 1 commit
    • sof's avatar
      [project @ 1998-02-25 19:48:54 by sof] · 33362962
      sof authored
      Interface file version checking support. Added a compiler version field
      to the interface file header. The format is now
      
        _interface_ <IfaceName> <ModuleVersion> <CompilerVersion>
      
      where the compiler version follow the value of $(ProjectVersionInt).
      Any mismatch in version numbers causes the renamer to give up.
      
      A compiler version number of 0 means turn off version checking (used
      by PrelGHC.hi to avoid having to update every time we release.)
      
      .hi-boot files are treated specially, the absence of a compiler
      version number in the header is taken to mean that there was a `0'.
      Need to do this since hsc's .hi-boot files have to also be useable
      by versions of the compiler that don't grok version info in interface
      files (e.g., ghc-2.10.)
      33362962
  31. 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
  32. 05 Sep, 1997 1 commit
  33. 05 Jul, 1997 1 commit
  34. 05 Jun, 1997 1 commit
  35. 26 May, 1997 1 commit
  36. 19 May, 1997 1 commit
  37. 14 Mar, 1997 1 commit
  38. 18 Jan, 1997 1 commit
  39. 06 Jan, 1997 1 commit