1. 23 Jun, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-06-23 10:35:15 by simonpj] · d28ba8c8
      simonpj authored
      -------------------
      	Dealing with 'main'
      	-------------------
      
      1.  In GHC 6.0, a module with no "module Main ... where" header
          elicited an error "main is not in scope" if 'main' is not defined.  We
          don't want this behaviour in GHCi.  This happened because the parser
          expanded the (absent) header to "module Main( main ) where", and the
          'main' in the export list isn't.
      
      Solution: elaborate HsModule to record whether the 'module ..." header was
      given explicitly by the user or not.
      
      
      2.  Add a -main-is flag, and document it, so that you can have a 'main' function
      that is not Main.main.  Summary of changes
      
      * The -main-is flag nominates what the main function is to be (see the documentation).
      	No -main-is flag 	says that the main function is Main.main
      	-main-is Foo.baz	says that the main function is Foo.baz
      	-main-is Foo		says that the main function is Foo.main
      	-main-is baz		says that the main function is Main.baz
      
        Let's say  you say -main-is Foo.baz
      
      * TcRnDriver injects the extra definition
      	$Mian.main :: IO t
      	$Main.main = baz
        in the module Foo.   Note the naming, which is a bit different than before;
        previously the extra defn was for Main.$main.  The RTS invokes zdMain_main_closure.
      
      * CodeGen injects an extra initialisation block into module Foo, thus
      	stginit_zdMain {
      		stginit_Foo
      	}
        That ensures that the RTS can initialise stginit_zdMain.
      d28ba8c8
  2. 20 Jun, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-06-20 11:14:18 by simonpj] · 1f861358
      simonpj authored
      ------------------------------
      	Fix a small quantification bug
      	------------------------------
      
      We were quantifying over too few type variables, because fdPredsOfInsts was
      being too eager to discard predicates. This only affects rather obscure
      programs.  Here's the one Iavor found:
      
      	class C a b where f :: a -> b
      	g x = fst (f x)
      
      We want to get the type
         	g :: forall a b c.  C a (b,c) => a -> b
      but GHC 6.0 bogusly gets
         	g :: forall a b.  C a (b,()) => a -> b
      
      A test is in should_compile/tc168
      1f861358
  3. 16 Jun, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-06-16 15:31:13 by simonpj] · 76c6edcb
      simonpj authored
      ----------------------------------
      	Fix the "no interface file" bug
      	----------------------------------
      
      The problem was this.
      
      * Module A imports module B
      
      * ghc --make A
      
      * Remove B.hs, B.hi, and edit A so that it doesn't import B
      
      * ghc --make A
      
      Then GHC would fail, saying it can't find an interface file for B.
      Reason: when loading A.hi (loadOldIface) it makes a Name for the
      usages it finds.  To make a Name for B things, it needs B's package;
      but it can't find B.hi, so it bombs instead.
      
      Solution: don't complain if loadOldIface fails; instead behave just like
      if you can't find A.hi.
      
      Fixes a long-standing infelicity.
      76c6edcb
  4. 06 May, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-05-06 10:25:32 by simonpj] · e4abae1d
      simonpj authored
      -------------------------------------
      		Main module exports
      	-------------------------------------
      
      Make it so that
      
         	    module Main where ....
      
      exports everything defined in Main, as the report says it should.
      e4abae1d
  5. 16 Apr, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-04-16 13:34:13 by simonpj] · 221b6b69
      simonpj authored
      ----------------------------------
       Use the Infer/Check idea for typechecking higher-rank types
      	----------------------------------
      
      The main idea is that
      
      	data Expected ty = Infer (TcRef ty) | Check ty
      
      	tcMonoExpr :: Expr -> Expected TcRhoType -> TcM Expra
      
      
      This "Expected" type tells tcMonoExpr whether it's doing inference or
      checking.  It replaces the "HoleTv" flavour of type variable.
      
      This actually leads to slightly more lines of code, but it's much
      clearer, and the new type distinctions showed up several subtle bugs
      in the previous implementation.  It all arose out of writing the
      prototype implementation for the paper.
      
      Error messages wibble around a little bit.  I'm not quite certain why!  But the
      changes look like improvements to me.
      221b6b69
  6. 27 Mar, 2003 1 commit
  7. 21 Feb, 2003 4 commits
    • simonpj's avatar
      [project @ 2003-02-21 14:52:54 by simonpj] · d6b7d200
      simonpj authored
      Typos
      d6b7d200
    • simonpj's avatar
      [project @ 2003-02-21 13:27:53 by simonpj] · 84ed91ab
      simonpj authored
      -------------------------------------
      	Improve the "unused binding" warnings
      	-------------------------------------
      
      We've had a succession of hacks for reporting warnings for
      unused bindings.  Consider
      
      	module M( f ) where
      
       	f x = x
      
      	g x = g x + h x
      	h x = x
      
      Here, g mentions itself and h, but is not itself mentioned. So
      really both g and h are dead code.  We've been getting this wrong
      for ages, and every hack so far has failed on some simple programs.
      
      This commit does a much better job.  The renamer applied to a bunch
      of bindings returns a NameSet.DefUses, which is a dependency-ordered
      lists of def/use pairs.  It's documented in NameSet.
      Given this, we can work out precisely what is not used, in a nice
      tidy way.
      
      It's less convenient in the case of type and class declarations, because
      the strongly-connected-component analysis can span module boundaries.
      So things are pretty much as they were for these.
      
      
      As usual, there was a lot of chuffing around tidying things up.
      I havn't tested it at all thoroughly yet.
      
      Various unrelated import-decl-pruning has been done too.
      84ed91ab
    • simonpj's avatar
      [project @ 2003-02-21 12:28:35 by simonpj] · 136d6345
      simonpj authored
      Another typo; sigh
      136d6345
    • simonpj's avatar
      [project @ 2003-02-21 12:16:44 by simonpj] · 802b299f
      simonpj authored
      Debugging hook jiggling
      802b299f
  8. 20 Feb, 2003 1 commit
  9. 14 Feb, 2003 2 commits
    • panne's avatar
      [project @ 2003-02-14 19:21:57 by panne] · 5ee05a2b
      panne authored
      Not sure if this fix is correct, but at least this module compiles
      again...
      5ee05a2b
    • simonpj's avatar
      [project @ 2003-02-14 14:22:24 by simonpj] · 5538aeeb
      simonpj authored
      -------------------------------------
         Do the top-level tcSimpifyTop (to resolve monomorphic constraints)
         once for the whole program, rather than once per splice group
      	-------------------------------------
      
      This change makes the trivial program
      
      	main = return ()
      
      work again.  It had stopped working (emitting an error about Monad m
      being unconstrained) because the 'checkMain' stuff (which knows special
      things about 'main' was happening only *after* all the groups of
      decls in the module had been dealt with and zonked (incl tcSimplifyTop).
      
      Better to postpone.  A little more plumbing, but one fewer unexpected
      happenings.
      5538aeeb
  10. 12 Feb, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-02-12 15:01:31 by simonpj] · 42b63073
      simonpj authored
      -------------------------------------
        Big upheaval to the way that constructors are named
      	-------------------------------------
      
      This commit enshrines the new story for constructor names.  We could never
      really get External Core to work nicely before, but now it does.
      
      The story is laid out in detail in the Commentary
      	ghc/docs/comm/the-beast/data-types.html
      so I will not repeat it here.
      
      	[Manuel: the commentary isn't being updated, apparently.]
      
      However, the net effect is that in Core and in External Core, contructors look
      like constructors, and the way things are printed is all consistent.
      
      It is a fairly pervasive change (which is why it has been so long postponed),
      but I hope the question is now finally closed.
      
      All the libraries compile etc, and I've run many tests, but doubtless there will
      be some dark corners.
      42b63073
  11. 04 Feb, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-02-04 12:33:05 by simonpj] · e6d00492
      simonpj authored
      ---------------------------------------------------
      	Template-Haskell fix to make the global environment
      		      more side-effect-ful
      	---------------------------------------------------
      
      Consider
      
      	f = $(...foldl...) $(...foldl...)
      
      The first splice sucks in the type sig for foldl, which the second
      splice needs.  That means that the second splice is going to have to
      consult the persistent compiler state to see the effect of imports
      by the first one.
      
      We used to cache the global type environment in the TcGblEnv, but
      this commit switches to the obvious thing: consult the persistent
      state on every global lookup.  After all, reading a MutVar is no
      big deal; and it's a benign, ever-growing cache of type signatures,
      so the side effect is fine.
      
      On the way I tidied up the knot-tying in TcIfaceSig a bit more.
      Previously, I think the setUnfoldingInfo was being strict in the
      unfolding, which forced it to be type-checked.  Now it's lazy.
      That could mean a lot less typechecking overall, for things whose
      unfolding isn't looked at.  I hope I havn't broken it, though.
      e6d00492
  12. 13 Jan, 2003 2 commits
  13. 10 Jan, 2003 1 commit
  14. 06 Jan, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-01-06 15:30:14 by simonpj] · fcf37c94
      simonpj authored
      --------------------------------------------------------------
      	Several small but tiresome things shown up by Template Haskell
      	--------------------------------------------------------------
      
      1. Make the 'knot' in TcRnDriver much smaller; in fact move it to
         TcIfaceSig.tcInterfaceSigs.  Reasons
      	a) much tidier
      	b) avoids a loop in Template Haskell, when we try to run
      	   an expression during type checking (when the knot is
      	   not fully tied)
      
         See comments in TcIfaceSig
      
      2. Stop typechecking if tcGroup fails.  Reason: otherwise tcLookup can
         fail in the next group.
      
      3. Catch linking errors more gracefully when running a splice (in TcSplice)
      fcf37c94
  15. 28 Nov, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-11-28 17:17:41 by simonpj] · 3c58c25b
      simonpj authored
      -------------------------------
            A day's work to improve error messages
      	-------------------------------
      
      1.  Indicate when the cause of the error is likely to be the monomorpism
          restriction, and identify the offending variables.  This involves
          mainly tcSimplifyTop and its error generation.
      
      2.  Produce much better kind error messages.  No more
            ../alonzo/DiGraph.hs:40:
      	  Couldn't match `* -> *' against `Type bx'
      	      Expected kind: * -> *
      	      Inferred kind: Type bx
      	  When checking that `DiGraph n' is a type
      
      It took a surprisingly long time to get the details right.
      3c58c25b
  16. 21 Nov, 2002 1 commit
  17. 20 Nov, 2002 2 commits
    • simonpj's avatar
      [project @ 2002-11-20 15:40:32 by simonpj] · c0624c76
      simonpj authored
      Wibble to fix :info
      c0624c76
    • chak's avatar
      [project @ 2002-11-20 12:34:42 by chak] · cda70f58
      chak authored
      TH:
      - We are forcing importing THSyntax.Q at every top splice now; this suffices
        to get simple splices that do not involve reifyDecl or declaration
        quasi-quotes to work.  NB: This worked already when the construction of the
        Dec term and the splice were in separated modules, but not when they are in
        the same (see the regression test "TH_spliceDecl1.hs").
      - The tests "TH_spliceDecl2.hs" and "TH_spliceDecl3.hs" use toplevel splices
        together with quasi-quoted and reifyDecl.  These currently still fail, as
        importing of some of the required type constructors from THSyntax isn't
        forced.
      cda70f58
  18. 25 Oct, 2002 2 commits
    • simonpj's avatar
      [project @ 2002-10-25 21:58:24 by simonpj] · 264cc860
      simonpj authored
      Import wibbles
      264cc860
    • simonpj's avatar
      [project @ 2002-10-25 15:23:03 by simonpj] · 4ef18ea2
      simonpj authored
      ------------------------
      	More dependency fiddling
      	------------------------
      
      	WARNING: Interface file format has changed (again)
      		 You need to 'make clean' in all library code
      
      * Orphan modules are now kept separately
        Home-package dependencies now contain only home-package dependencies!
        See HscTypes.Dependencies
      
      * Linker now uses the dependencies to do dynamic linking
      
      Result: Template Haskell should work even without --make (not yet tested)
      4ef18ea2
  19. 24 Oct, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-10-24 14:17:46 by simonpj] · e0445ffa
      simonpj authored
      ------------------------------------------
      	1. New try and module and package dependencies
      	2. OrigNameCache always contains final info
      	------------------------------------------
      
      These things nearly complete sorting out the incremental
      linking problem that started us off!
      
      1. This commit separates two kinds of information:
      
        (a) HscTypes.Dependencies:
      	What (i)  home-package modules, and
      	     (ii) other packages
            this module depends on, transitively.
      
            That is, to link the module, it should be enough
            to link the dependent modules and packages (plus
            any C stubs etc).
      
            Along with this info we record whether the dependent module
            is (a) a boot interface or (b) an orphan module.  So in
            fact (i) can contain non-home-package modules, namely the
            orphan ones in other packages (sigh).
      
        (b) HscTypes.Usage:
            What version of imported things were used to
            actually compile the module.  This info is used for
            recompilation control only.
      
      
      
      2. The Finder now returns a correct Module (incl package indicator)
      first time, so we can install the absolutely final Name in the
      OrigNameCache when we first come across an occurrence of that name,
      even if it's only an occurrence in an unfolding in some other interface
      file.  This is much tidier.
      
      As a result Module.lhs is much cleaner
      	No DunnoYet
      	No mkVanillaModule
      ALl very joyful stuff.
      e0445ffa
  20. 18 Oct, 2002 1 commit
  21. 15 Oct, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-10-15 11:52:31 by simonpj] · 5c614bc5
      simonpj authored
      ------------------------------------------------
      	Fix exports for a module with  no local bindings
      	------------------------------------------------
      
      Fix the export-list generation for a module with no local bindings.
      This one bug was breaking a bunch of modxxx tests, plus some renamer
      test, plus a desugarer test.
      5c614bc5
  22. 09 Oct, 2002 4 commits
  23. 27 Sep, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-09-27 08:20:43 by simonpj] · dbc254c3
      simonpj authored
      --------------------------------
              Implement recursive do-notation
      	--------------------------------
      
      This commit adds recursive do-notation, which Hugs has had for some time.
      
      	mdo { x <- foo y ;
      	      y <- baz x ;
      	      return (y,x) }
      
      turns into
      
      	do { (x,y) <- mfix (\~(x,y) -> do { x <- foo y;
      					    y <- baz x }) ;
      	     return (y,x) }
      
      This is all based on work by Levent Erkok and John Lanuchbury.
      
      The really tricky bit is in the renamer (RnExpr.rnMDoStmts) where
      we break things up into minimal segments.  The rest is easy, including
      the type checker.
      
      Levent laid the groundwork, and Simon finished it off. Needless to say,
      I couldn't resist tidying up other stuff, so there's no guaranteed I
      have not broken something.
      dbc254c3
  24. 17 Sep, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-09-17 13:00:14 by simonpj] · 451a42dc
      simonpj authored
      --------------------------------------
      	Another attempt to make unbound type
      	variables in RULES work right
      	--------------------------------------
      
      Sigh.  I'm trying to find the unbound type variables on the LHS of a
      RULE.  I thought I could just gather free vars, but that does not work
      well on an un-zonked LHS, because a big lambda might bind a type variable
      that looks different (pre-zonking) but isn't really.
      
      Oh well, back to plan B which is more work but more robust.
      
      Now the zonking phase (in TcHsSyn) arranges to zonk types in a different
      way (zonkTypeCollecting) on a rule LHS than in ordinary expressions
      (zonkTypeZapping).  This is less dependent on the exact form of the LHS
      (good) but involves another mutable variable (not unclean, but it's sad
      to have to admit that mutable variables do sometimes allow you to make
      non-invasive changes).
      451a42dc
  25. 13 Sep, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-09-13 15:02:25 by simonpj] · 9af77fa4
      simonpj authored
      --------------------------------------
      	Make Template Haskell into the HEAD
      	--------------------------------------
      
      This massive commit transfers to the HEAD all the stuff that
      Simon and Tim have been doing on Template Haskell.  The
      meta-haskell-branch is no more!
      
      WARNING: make sure that you
      
        * Update your links if you are using link trees.
          Some modules have been added, some have gone away.
      
        * Do 'make clean' in all library trees.
          The interface file format has changed, and you can
          get strange panics (sadly) if GHC tries to read old interface files:
          e.g.  ghc-5.05: panic! (the `impossible' happened, GHC version 5.05):
      	  Binary.get(TyClDecl): ForeignType
      
        * You need to recompile the rts too; Linker.c has changed
      
      
      However the libraries are almost unaltered; just a tiny change in
      Base, and to the exports in Prelude.
      
      
      NOTE: so far as TH itself is concerned, expression splices work
      fine, but declaration splices are not complete.
      
      
      		---------------
      		The main change
      		---------------
      
      The main structural change: renaming and typechecking have to be
      interleaved, because we can't rename stuff after a declaration splice
      until after we've typechecked the stuff before (and the splice
      itself).
      
      * Combine the renamer and typecheker monads into one
      	(TcRnMonad, TcRnTypes)
        These two replace TcMonad and RnMonad
      
      * Give them a single 'driver' (TcRnDriver).  This driver
        replaces TcModule.lhs and Rename.lhs
      
      * The haskell-src library package has a module
      	Language/Haskell/THSyntax
        which defines the Haskell data type seen by the TH programmer.
      
      * New modules:
      	hsSyn/Convert.hs 	converts THSyntax -> HsSyn
      	deSugar/DsMeta.hs 	converts HsSyn -> THSyntax
      
      * New module typecheck/TcSplice type-checks Template Haskell splices.
      
      		-------------
      		Linking stuff
      		-------------
      
      * ByteCodeLink has been split into
      	ByteCodeLink	(which links)
      	ByteCodeAsm	(which assembles)
      
      * New module ghci/ObjLink is the object-code linker.
      
      * compMan/CmLink is removed entirely (was out of place)
        Ditto CmTypes (which was tiny)
      
      * Linker.c initialises the linker when it is first used (no need to call
        initLinker any more).  Template Haskell makes it harder to know when
        and whether to initialise the linker.
      
      
      	-------------------------------------
      	Gathering the LIE in the type checker
      	-------------------------------------
      
      * Instead of explicitly gathering constraints in the LIE
      	tcExpr :: RenamedExpr -> TcM (TypecheckedExpr, LIE)
        we now dump the constraints into a mutable varabiable carried
        by the monad, so we get
      	tcExpr :: RenamedExpr -> TcM TypecheckedExpr
      
        Much less clutter in the code, and more efficient too.
        (Originally suggested by Mark Shields.)
      
      
      		-----------------
      		Remove "SysNames"
      		-----------------
      
      Because the renamer and the type checker were entirely separate,
      we had to carry some rather tiresome implicit binders (or "SysNames")
      along inside some of the HsDecl data structures.  They were both
      tiresome and fragile.
      
      Now that the typechecker and renamer are more intimately coupled,
      we can eliminate SysNames (well, mostly... default methods still
      carry something similar).
      
      		-------------
      		Clean up HsPat
      		-------------
      
      One big clean up is this: instead of having two HsPat types (InPat and
      OutPat), they are now combined into one.  This is more consistent with
      the way that HsExpr etc is handled; there are some 'Out' constructors
      for the type checker output.
      
      So:
      	HsPat.InPat	--> HsPat.Pat
      	HsPat.OutPat	--> HsPat.Pat
      	No 'pat' type parameter in HsExpr, HsBinds, etc
      
      	Constructor patterns are nicer now: they use
      		HsPat.HsConDetails
      	for the three cases of constructor patterns:
      		prefix, infix, and record-bindings
      
      	The *same* data type HsConDetails is used in the type
      	declaration of the data type (HsDecls.TyData)
      
      Lots of associated clean-up operations here and there.  Less code.
      Everything is wonderful.
      9af77fa4