1. 20 Feb, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-02-20 18:33:50 by simonpj] · 56b5a8b8
      simonpj authored
      -------------------------------------
            Add Core Notes and the {-# CORE #-} pragma
      	-------------------------------------
      
      This is an idea of Hal Daume's. The key point is that Notes in Core
      are augmented thus:
      
        data Note
          = SCC CostCentre
          | ...
          | CoreNote String     -- NEW
      
      These notes can be injected via a Haskell-source pragma:
      
         f x = ({-# CORE "foo" #-} show) ({-# CORE "bar" #-} x)
      
      This wraps a (Note (CoreNote "foo")) around the 'show' variable,
      and a similar note around the argument to 'show'.
      
      These notes are basically ignored by GHC, but are emitted into
      External Core, where they may convey useful information.
      
      Exactly how code involving these notes is munged by the simplifier
      isn't very well defined.  We'll see how it pans out.  Meanwhile
      the impact on the rest of the compiler is minimal.
      56b5a8b8
  2. 10 Dec, 2002 2 commits
  3. 28 Nov, 2002 1 commit
  4. 05 Nov, 2002 1 commit
  5. 23 Oct, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-10-23 14:30:00 by simonpj] · 203a687f
      simonpj authored
      ------------------------------------------------
      	Allow implicit-parameter bindings anywhere that
      		a normal binding group is allowed.
      	------------------------------------------------
      
      That is, you can have implicit parameters
      
      	* in a let binding
      	* in a where clause (but then you can't have non-implicit
      	  ones as well)
      	* in a let group in a list comprehension or monad do-notation
      
      The implementation is simple: just add IPBinds to the allowable forms of HsBinds,
      and remove the HsWith expression form altogether.   (It now comes in via the
      HsLet form.)
      
      It'a a nice generalisation really.  Needs a bit of documentation, which I'll do next.
      203a687f
  6. 11 Oct, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-10-11 14:46:02 by simonpj] · cbb5beb0
      simonpj authored
      ------------------------------------------
      	Implement reification for Template Haskell
      	------------------------------------------
      
      This is entirely un-tested, but I don't think it'll break non-TH stuff.
      
      Implements
      	reifyDecl T :: Dec	-- Data type T
      	reifyDecl C :: Dec	-- Class C
      	reifyType f :: Typ	-- Function f
      
      I hope.
      cbb5beb0
  7. 09 Oct, 2002 2 commits
    • simonpj's avatar
      [project @ 2002-10-09 16:53:10 by simonpj] · aadb64aa
      simonpj authored
      Fix to mdo, plus SrcLocs on splices and brackets
      aadb64aa
    • simonpj's avatar
      [project @ 2002-10-09 15:03:48 by simonpj] · 8c1b6bd7
      simonpj authored
      -----------------------------------
      	Lots more Template Haskell stuff
      	-----------------------------------
      
      At last!  Top-level declaration splices work!
      Syntax is
      
      	$(f x)
      
      not "splice (f x)" as in the paper.
      
      Lots jiggling around, particularly with the top-level plumbining.
      Note the new data type HsDecls.HsGroup.
      8c1b6bd7
  8. 30 Sep, 2002 1 commit
  9. 27 Sep, 2002 3 commits
    • erkok's avatar
      [project @ 2002-09-27 17:12:23 by erkok] · 0043e4e0
      erkok authored
      make sure we get the name right when we call doStmtListErr
      0043e4e0
    • simonpj's avatar
      [project @ 2002-09-27 12:42:42 by simonpj] · 278092c8
      simonpj authored
      Wibbles to improve error reporting
      278092c8
    • 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
  10. 25 Sep, 2002 1 commit
  11. 13 Sep, 2002 2 commits
    • 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
    • simonpj's avatar
      [project @ 2002-09-13 08:54:44 by simonpj] · 7e2009cf
      simonpj authored
      Correct comments
      7e2009cf
  12. 29 Jul, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-07-29 12:22:37 by simonpj] · 2ddea0a8
      simonpj authored
      *** MERGE TO STABLE BRANCH ***
      
      
      Surprisingly large delta to make rebindable names work properly.
      I was sloppily not checking the type of the user-supplied name,
      and Ashley Yakeley's first experiment showed up the problem!
      
      Solution: typechecker has to check both the 'standard' name and
      the 'user' name and check the latter has a type compatible with the
      former.
      
      The main comment is with Inst.tcSyntaxName (a new function).
      2ddea0a8
  13. 06 Jun, 2002 1 commit
  14. 05 Jun, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-06-05 14:39:27 by simonpj] · b2f644fa
      simonpj authored
      ---------------------------------------
      	Add rebindable syntax for do-notation
      		(this time, on the HEAD)
      	---------------------------------------
      
      Make do-notation use rebindable syntax, so that -fno-implicit-prelude
      makes do-notation use whatever (>>=), (>>), return, fail are in scope,
      rather than the Prelude versions.
      
      On the way, combine HsDo and HsDoOut into one constructor in HsSyn,
      and tidy up type checking of HsDo.
      b2f644fa
  15. 27 May, 2002 2 commits
    • simonpj's avatar
      [project @ 2002-05-27 16:13:42 by simonpj] · fd7d044f
      simonpj authored
      Make negative literals work in patterns
      
      The issue here is that
      
      	f (-1) = True
      	f x    = False
      
      should generate
      
      	f x = x == negate (fromInteger 1)
      
      rather than
      
      	f x = x == fromInteger (-1)
      fd7d044f
    • simonpj's avatar
      [project @ 2002-05-27 15:28:07 by simonpj] · ef2b170c
      simonpj authored
      Allow infix type constructors
      
      This commit adds infix type constructors (but not yet class constructors).
      The documentation describes what should be the case.  Lots of tiresome
      changes, but nothing exciting.
      
      Allows infix type constructors everwhere a type can occur, and in a data
      or type synonym decl.  E.g.
      
      	data a :*: b = ....
      
      
      You can give fixity decls for type constructors, but the fixity decl
      applies both to the tycon and the corresponding data con.
      ef2b170c
  16. 29 Apr, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-04-29 14:03:38 by simonmar] · b085ee40
      simonmar authored
      FastString cleanup, stage 1.
      
      The FastString type is no longer a mixture of hashed strings and
      literal strings, it contains hashed strings only with O(1) comparison
      (except for UnicodeStr, but that will also go away in due course).  To
      create a literal instance of FastString, use FSLIT("..").
      
      By far the most common use of the old literal version of FastString
      was in the pattern
      
      	  ptext SLIT("...")
      
      this combination still works, although it doesn't go via FastString
      any more.  The next stage will be to remove the need to use this
      special combination at all, using a RULE.
      
      To convert a FastString into an SDoc, now use 'ftext' instead of
      'ptext'.
      
      I've also removed all the FAST_STRING related macros from HsVersions.h
      except for SLIT and FSLIT, just use the relevant functions from
      FastString instead.
      b085ee40
  17. 11 Apr, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-04-11 12:03:29 by simonpj] · a7b95beb
      simonpj authored
      -------------------
      	Mainly derived Read
      	-------------------
      
      This commit is a tangle of several things that somehow got wound up
      together, I'm afraid.
      
      
      The main course
      ~~~~~~~~~~~~~~~
      Replace the derived-Read machinery with Koen's cunning new parser
      combinator library.   The result should be
      	* much smaller code sizes from derived Read
      	* faster execution of derived Read
      
      WARNING: I have not thoroughly tested this stuff; I'd be glad if you did!
      	 All the hard work is done, but there may be a few nits.
      
      The Read class gets two new methods, not exposed
      in the H98 inteface of course:
        class Read a where
          readsPrec    :: Int -> ReadS a
          readList     :: ReadS [a]
          readPrec     :: ReadPrec a		-- NEW
          readListPrec :: ReadPrec [a]	-- NEW
      
      There are the following new libraries:
      
        Text.ParserCombinators.ReadP		Koens combinator parser
        Text.ParserCombinators.ReadPrec	Ditto, but with precedences
      
        Text.Read.Lex				An emasculated lexical analyser
      					that provides the functionality
      					of H98 'lex'
      
      TcGenDeriv is changed to generate code that uses the new libraries.
      The built-in instances of Read (List, Maybe, tuples, etc) use the new
      libraries.
      
      
      Other stuff
      ~~~~~~~~~~~
      1. Some fixes the the plumbing of external-core generation. Sigbjorn
      did most of the work earlier, but this commit completes the renaming and
      typechecking plumbing.
      
      2. Runtime error-generation functions, such as GHC.Err.recSelErr,
      GHC.Err.recUpdErr, etc, now take an Addr#, pointing to a UTF8-encoded
      C string, instead of a Haskell string.  This makes the *calls* to these
      functions easier to generate, and smaller too, which is a good thing.
      
      In particular, it means that MkId.mkRecordSelectorId doesn't need to
      be passed "unpackCStringId", which was GRUESOME; and that in turn means
      that tcTypeAndClassDecls doesn't need to be passed unf_env, which is
      a very worthwhile cleanup.   Win/win situation.
      
      3.  GHC now faithfully translates do-notation using ">>" for statements
      with no binding, just as the report says.  While I was there I tidied
      up HsDo to take a list of Ids instead of 3 (but now 4) separate Ids.
      Saves a bit of code here and there.  Also introduced Inst.newMethodFromName
      to package a common idiom.
      a7b95beb
  18. 02 Apr, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-04-02 13:56:32 by simonmar] · 94c5c5a2
      simonmar authored
      Allow the use of 'let' for implcit bindings.
      
      Support for 'with' is left in place for the time being, but on seeing
      a 'with' we emit a non-suppressible warning about 'with' being
      deprecated in favour of 'let'.
      94c5c5a2
  19. 14 Mar, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-03-14 15:27:15 by simonpj] · 1553c778
      simonpj authored
      ------------------------
      	Change
      		GlobalName --> ExternalName
      		LocalName  ->  InternalName
      	------------------------
      
      For a long time there's been terminological confusion between
      
      	GlobalName vs LocalName	 (property of a Name)
      	GlobalId vs LocalId	 (property of an Id)
      
      I've now changed the terminology for Name to be
      
      	ExternalName vs InternalName
      
      I've also added quite a bit of documentation in the Commentary.
      1553c778
  20. 04 Mar, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-03-04 17:01:26 by simonmar] · 0171936c
      simonmar authored
      Binary Interface Files - stage 1
      --------------------------------
      
      This commit changes the default interface file format from text to
      binary, in order to improve compilation performace.
      
      To view an interface file, use 'ghc --show-iface Foo.hi'.
      
      utils/Binary.hs is the basic Binary I/O library, based on the nhc98
      binary I/O library but much stripped-down and working in terms of
      bytes rather than bits, and with some special features for GHC: it
      remembers which Module is being emitted to avoid dumping too many
      qualified names, and it keeps track of a "dictionary" of FastStrings
      so that we don't dump the same FastString more than once into the
      binary file.  I'll make a generic version of this for the libraries at
      some point.
      
      main/BinIface.hs contains most of the Binary instances.  Some
      instances are in the same module as the data type (RdrName, Name,
      OccName in particular).  Most instances were generated using a
      modified version of DrIFT, which I'll commit later.  However, editing
      them by hand isn't hard (certainly easier than modifying
      ParseIface.y).
      
      The first thing in a binary interface is the interface version, so
      nice error messages will be generated if the binary format changes and
      you still have old interfaces lying around.  The version also now
      includes the "way" as an extra sanity check.
      
      Other changes
      -------------
      
      I don't like the way FastStrings contain both hashed strings (with
      O(1) comparison) and literal C strings (with O(n) comparison).  So as
      a first step to separating these I made serveral "literal" type
      strings into hashed strings.  SLIT() still generates a literal, and
      now FSLIT() generates a hashed string.  With DEBUG on, you'll get a
      warning if you try to compare any SLIT()s with anything, and the
      compiler will fall over if you try to dump any literal C strings into
      an interface file (usually indicating a use of SLIT() which should be
      FSLIT()).
      
      mkSysLocal no longer re-encodes its FastString argument each time it
      is called.
      
      I also fixed the -pgm options so that the argument can now optionally
      be separted from the option.
      
      Bugfix: PrelNames declared Names for several comparison primops, eg.
      eqCharName, eqIntName etc. but these had different uniques from the
      real primop names.  I've moved these to PrimOps and defined them using
      mkPrimOpIdName instead, and deleted some for which we don't have real
      primops (Manuel: please check that things still work for you after
      this change).
      0171936c
  21. 13 Feb, 2002 1 commit
  22. 11 Feb, 2002 1 commit
    • chak's avatar
      [project @ 2002-02-11 08:20:38 by chak] · 10fcd78c
      chak authored
      *******************************
      		       * Merging from ghc-ndp-branch *
      		       *******************************
      
      This commit merges the current state of the "parallel array extension" and
      includes the following:
      
      * (Almost) completed Milestone 1:
        - The option `-fparr' activates the H98 extension for parallel arrays.
        - These changes have a high likelihood of conflicting (in the CVS sense)
          with other changes to GHC and are the reason for merging now.
        - ToDo: There are still some (less often used) functions not implemented in
      	  `PrelPArr' and a mechanism is needed to automatically import
      	  `PrelPArr' iff `-fparr' is given.  Documentation that should go into
      	  the Commentary is currently in `ghc/compiler/ndpFlatten/TODO'.
      
      * Partial Milestone 2:
        - The option `-fflatten' activates the flattening transformation and `-ndp'
          selects the "ndp" way (where all libraries have to be compiled with
          flattening).  The way option `-ndp' automagically turns on `-fparr' and
          `-fflatten'.
        - Almost all changes are in the new directory `ndpFlatten' and shouldn't
          affect the rest of the compiler.  The only exception are the options and
          the points in `HscMain' where the flattening phase is called when
          `-fflatten' is given.
        - This isn't usable yet, but already implements function lifting,
          vectorisation, and a new analysis that determines which parts of a module
          have to undergo the flattening transformation.  Missing are data structure
          and function specialisation, the unboxed array library (including fusion
          rules), and lots of testing.
      
      I have just run the regression tests on the thing without any problems.  So,
      it seems, as if we haven't broken anything crucial.
      10fcd78c
  23. 29 Nov, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-11-29 13:47:09 by simonpj] · 32a89583
      simonpj authored
      ------------------------------
      	Add linear implicit parameters
      	------------------------------
      
      Linear implicit parameters are an idea developed by Koen Claessen,
      Mark Shields, and Simon PJ, last week.  They address the long-standing
      problem that monads seem over-kill for certain sorts of problem, notably:
      
      	* distributing a supply of unique names
      	* distributing a suppply of random numbers
      	* distributing an oracle (as in QuickCheck)
      
      
      Linear implicit parameters are just like ordinary implicit parameters,
      except that they are "linear" -- that is, they cannot be copied, and
      must be explicitly "split" instead.  Linear implicit parameters are
      written '%x' instead of '?x'.  (The '/' in the '%' suggests the
      split!)
      
      For example:
      
          data NameSupply = ...
      
          splitNS :: NameSupply -> (NameSupply, NameSupply)
          newName :: NameSupply -> Name
      
          instance PrelSplit.Splittable NameSupply where
      	split = splitNS
      
      
          f :: (%ns :: NameSupply) => Env -> Expr -> Expr
          f env (Lam x e) = Lam x' (f env e)
      		    where
      		      x'   = newName %ns
      		      env' = extend env x x'
          ...more equations for f...
      
      Notice that the implicit parameter %ns is consumed
      	once by the call to newName
      	once by the recursive call to f
      
      So the translation done by the type checker makes
      the parameter explicit:
      
          f :: NameSupply -> Env -> Expr -> Expr
          f ns env (Lam x e) = Lam x' (f ns1 env e)
      		       where
      	 		 (ns1,ns2) = splitNS ns
      			 x' = newName ns2
      			 env = extend env x x'
      
      Notice the call to 'split' introduced by the type checker.
      How did it know to use 'splitNS'?  Because what it really did
      was to introduce a call to the overloaded function 'split',
      ndefined by
      
      	class Splittable a where
      	  split :: a -> (a,a)
      
      The instance for Splittable NameSupply tells GHC how to implement
      split for name supplies.  But we can simply write
      
      	g x = (x, %ns, %ns)
      
      and GHC will infer
      
      	g :: (Splittable a, %ns :: a) => b -> (b,a,a)
      
      The Splittable class is built into GHC.  It's defined in PrelSplit,
      and exported by GlaExts.
      
      Other points:
      
      * '?x' and '%x' are entirely distinct implicit parameters: you
        can use them together and they won't intefere with each other.
      
      * You can bind linear implicit parameters in 'with' clauses.
      
      * You cannot have implicit parameters (whether linear or not)
        in the context of a class or instance declaration.
      
      
      Warnings
      ~~~~~~~~
      The monomorphism restriction is even more important than usual.
      Consider the example above:
      
          f :: (%ns :: NameSupply) => Env -> Expr -> Expr
          f env (Lam x e) = Lam x' (f env e)
      		    where
      		      x'   = newName %ns
      		      env' = extend env x x'
      
      If we replaced the two occurrences of x' by (newName %ns), which is
      usually a harmless thing to do, we get:
      
          f :: (%ns :: NameSupply) => Env -> Expr -> Expr
          f env (Lam x e) = Lam (newName %ns) (f env e)
      		    where
      		      env' = extend env x (newName %ns)
      
      But now the name supply is consumed in *three* places
      (the two calls to newName,and the recursive call to f), so
      the result is utterly different.  Urk!  We don't even have
      the beta rule.
      
      Well, this is an experimental change.  With implicit
      parameters we have already lost beta reduction anyway, and
      (as John Launchbury puts it) we can't sensibly reason about
      Haskell programs without knowing their typing.
      
      Of course, none of this is throughly tested, either.
      32a89583
  24. 31 Oct, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-10-31 15:22:53 by simonpj] · 61bfd5dd
      simonpj authored
      ------------------------------------------
      	Improved handling of scoped type variables
      	------------------------------------------
      
      The main effect of this commit is to allow scoped type variables
      in pattern bindings, thus
      
      	(x::a, y::b) = e
      
      This was illegal, but now it's ok.  a and b have the same scope
      as x and y.
      
      
      On the way I beefed up the info inside a type variable
      (TcType.TyVarDetails; c.f. IdInfo.GlobalIdDetails) which
      helps to improve error messages. Hence the wide ranging changes.
      Pity about the extra loop from Var to TcType, but can't be helped.
      61bfd5dd
  25. 26 Sep, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-09-26 15:12:33 by simonpj] · e0d750be
      simonpj authored
      ------------------
      		Simon's big commit
      		------------------
      
      This commit, which I don't think I can sensibly do piecemeal, consists
      of the things I've been doing recently, mainly directed at making
      Manuel, George, and Marcin happier with RULES.
      
      
      Reogranise the simplifier
      ~~~~~~~~~~~~~~~~~~~~~~~~~
      1. The simplifier's environment is now an explicit parameter.  This
      makes it a bit easier to figure out where it is going.
      
      2. Constructor arguments can now be arbitrary expressions, except
      when the application is the RHS of a let(rec).  This makes it much
      easier to match rules like
      
      	RULES
      	    "foo"  f (h x, g y) = f' x y
      
      In the simplifier, it's Simplify.mkAtomicArgs that ANF-ises a
      constructor application where necessary.  In the occurrence analyser,
      there's a new piece of context info (OccEncl) to say whether a
      constructor app is in a place where it should be in ANF.  (Unless
      it knows this it'll give occurrence info which will inline the
      argument back into the constructor app.)
      
      3. I'm experimenting with doing the "float-past big lambda" transformation
      in the full laziness pass, rather than mixed in with the simplifier (was
      tryRhsTyLam).
      
      4.  Arrange that
      	case (coerce (S,T) (x,y)) of ...
      will simplify.  Previous it didn't.
      A local change to CoreUtils.exprIsConApp_maybe.
      
      5. Do a better job in CoreUtils.exprEtaExpandArity when there's an
      error function in one branch.
      
      
      Phase numbers, RULES, and INLINE pragmas
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      1.  Phase numbers decrease from N towards zero (instead of increasing).
      This makes it easier to add new earlier phases, which is what users want
      to do.
      
      2.  RULES get their own phase number, N, and are disabled in phases before N.
      
      e.g. 	{-# RULES "foo" [2] forall x y.  f (x,y) = f' x y #-}
      
      Note the [2], which says "only active in phase 2 and later".
      
      3.  INLINE and NOINLINE pragmas have a phase number to.  This is now treated
      in just the same way as the phase number on RULE; that is, the Id is not inlined
      in phases earlier than N.  In phase N and later the Id *may* be inlined, and
      here is where INLINE and NOINLINE differ: INLNE makes the RHS look small, so
      as soon as it *may* be inlined it probably *will* be inlined.
      
      The syntax of the phase number on an INLINE/NOINLINE pragma has changed to be
      like the RULES case (i.e. in square brackets).  This should also make sure
      you examine all such phase numbers; many will need to change now the numbering
      is reversed.
      
      Inlining Ids is no longer affected at all by whether the Id appears on the
      LHS of a rule.  Now it's up to the programmer to put a suitable INLINE/NOINLINE
      pragma to stop it being inlined too early.
      
      
      Implementation notes:
      
      *  A new data type, BasicTypes.Activation says when a rule or inline pragma
      is active.   Functions isAlwaysActive, isNeverActive, isActive, do the
      obvious thing (all in BasicTypes).
      
      * Slight change in the SimplifierSwitch data type, which led to a lot of
      simplifier-specific code moving from CmdLineOpts to SimplMonad; a Good Thing.
      
      * The InlinePragma in the IdInfo of an Id is now simply an Activation saying
      when the Id can be inlined.  (It used to be a rather bizarre pair of a
      Bool and a (Maybe Phase), so this is much much easier to understand.)
      
      * The simplifier has a "mode" environment switch, replacing the old
      black list.  Unfortunately the data type decl has to be in
      CmdLineOpts, because it's an argument to the CoreDoSimplify switch
      
          data SimplifierMode = SimplGently | SimplPhase Int
      
      Here "gently" means "no rules, no inlining".   All the crucial
      inlining decisions are now collected together in SimplMonad
      (preInlineUnconditionally, postInlineUnconditionally, activeInline,
      activeRule).
      
      
      Specialisation
      ~~~~~~~~~~~~~~
      1.  Only dictionary *functions* are made INLINE, not dictionaries that
      have no parameters.  (This inline-dictionary-function thing is Marcin's
      idea and I'm still not sure whether it's a good idea.  But it's definitely
      a Bad Idea when there are no arguments.)
      
      2.  Be prepared to specialise an INLINE function: an easy fix in
      Specialise.lhs
      
      But there is still a problem, which is that the INLINE wins
      at the call site, so we don't use the specialised version anyway.
      I'm still unsure whether it makes sense to SPECIALISE something
      you want to INLINE.
      
      
      
      
      
      Random smaller things
      ~~~~~~~~~~~~~~~~~~~~~~
      
      * builtinRules (there was only one, but may be more) in PrelRules are now
        incorporated.   They were being ignored before...
      
      * OrdList.foldOL -->  OrdList.foldrOL, OrdList.foldlOL
      
      * Some tidying up of the tidyOpenTyVar, tidyTyVar functions.  I've
        forgotten exactly what!
      e0d750be
  26. 20 Sep, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-09-20 08:47:13 by simonpj] · 2c250999
      simonpj authored
      ------------------------------
      	Fix a scoped-type-variable bug
      	------------------------------
      
      	MERGE WITH STABLE BRANCH
      
      The bug caused an incorrect failure when the same type
      variable was used more than once in a collection of patterns:
      
      	f (x :: t) (y :: t) = e
      
      On the way, I eliminated bindNakedTyVarsFVRn, which was only
      called once.
      2c250999
  27. 23 Aug, 2001 2 commits
    • simonpj's avatar
      [project @ 2001-08-23 15:05:52 by simonpj] · f62fd70d
      simonpj authored
      More instance-gate fiddling.  This must be one of the most
      tiremsome bits of the entire compiler, and I appear to be
      incapable of modifying it without getting it wrong at least
      once.
      
      Still, this commit does tidy things up a bit.
      
      * The type renamers (rnHsType, etc) have moved from RnSource
        into a new module RnTypes.
      
      * This breaks a couple of loops, and lets us nuke RnSource.hi-boot.
        Hurrah!
      
      Simon
      f62fd70d
    • simonpj's avatar
      [project @ 2001-08-23 09:54:45 by simonpj] · 98bf5734
      simonpj authored
      --------------------------------------------------
      	Be a bit more liberal when slurping instance decls
      	--------------------------------------------------
      
      Functional dependencies have (as usual) made things more complicated
      
      Suppose an interface file contains
      	interface A where
      	  class C a b | a->b where op :: a->b
      	  instance C Foo Baz where ...
      
      Now we are compiling
      	module B where
      	  import A
      	  t = op (v::Foo)
      
      Should we slurp the instance decl, even though Baz is nowhere mentioned
      in module B?  YES!  Because of the fundep, the (C Foo ?) part is enough to
      select this instance decl, and the Baz part follows.
      
      Rather than take fundeps into account "properly", we just slurp
      if C is visible and *any one* of the Names in the types
      This is a slightly brutal approximation, but most instance decls
      are regular H98 ones and it's perfect for them.
      
      Changes:
      
        HscTypes:
      	generalise the types of GatedDecl a bit
      
        RnHiFiles.loadInstDecl, RnHiFiles.loadRule, RnIfaces.selectGated:
      	the meat of the solution
      
        RdrName, OccName etc:
      	some consequential wibbles
      98bf5734
  28. 20 Aug, 2001 1 commit
  29. 13 Jul, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-07-13 13:29:56 by simonpj] · d4e38936
      simonpj authored
      ------------------------------------
      	Tidy up the "syntax rebinding" story
      	------------------------------------
      
      I found a bug in the code that dealt with re-binding implicit
      numerical syntax:
      	literals 	(fromInteger/fromRational)
      	negation	(negate)
      	n+k patterns	(minus)
      
      This is triggered by the -fno-implicit-prelude flag, and it
      used to be handled via the PrelNames.SyntaxMap.
      
      But I found a nicer way to do it that involves much less code,
      and doesn't have the bug.  The explanation is with
      	RnEnv.lookupSyntaxName
      d4e38936
  30. 12 Jul, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-07-12 16:21:22 by simonpj] · ab46fd8e
      simonpj authored
      --------------------------------------------
      	Fix another bug in the squash-newtypes story.
      	--------------------------------------------
      
      [This one was spotted by Marcin, and is now enshrined in test tc130.]
      
      The desugarer straddles the boundary between the type checker and
      Core, so it sometimes needs to look through newtypes/implicit parameters
      and sometimes not.  This is really a bit painful, but I can't think of
      a better way to do it.
      
      The only simple way to fix things was to pass a bit more type
      information in the HsExpr type, from the type checker to the desugarer.
      That led to the non-local changes you can see.
      
      On the way I fixed one other thing.  In various HsSyn constructors
      there is a Type that is bogus (bottom) before the type checker, and
      filled in with a real type by the type checker.  In one place it was
      a (Maybe Type) which was Nothing before, and (Just ty) afterwards.
      I've defined a type synonym HsTypes.PostTcType for this, and a named
      bottom value HsTypes.placeHolderType to use when you want the bottom
      value.
      ab46fd8e
  31. 13 Jun, 2001 1 commit
  32. 11 Jun, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-06-11 12:24:51 by simonpj] · 2c6d73e2
      simonpj authored
      --------------------------------------
      	Tidy up and improve "pattern contexts"
      	--------------------------------------
      
      In various places (renamer, typechecker, desugarer) we need to know
      what the context of a pattern match is (case expression, function defn,
      let binding, etc).  This commit tidies up the story quite a bit.  I
      think it represents a net decrease in code, and certainly it improves the
      error messages from:
      
      	f x x = 3
      
      Prevsiously we got a message like "Conflicting bindings for x in a pattern match",
      but not it says "..in a defn of function f".
      
      WARNING: the tidy up had a more global effect than I originally expected,
      so it's possible that some other error messages look a bit peculiar.  They
      should be easy to fix, but tell us!
      2c6d73e2
  33. 28 May, 2001 1 commit