1. 17 Jan, 2008 1 commit
  2. 16 Jan, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Fix the -frule-check pass · 609db9ce
      simonpj@microsoft.com authored
      Rules for imported things are now kept in the global rule base, not
      attached to the global Id.  The rule-check pass hadn't kept up.
      
      This should fix it.
      609db9ce
  3. 20 Dec, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #1988; keep the ru_fn field of a RULE up to date · ca919ae0
      simonpj@microsoft.com authored
      The ru_fn field was wrong when we moved RULES from one Id to another.
      The fix is simple enough.
      
      However, looking at this makes me realise that the worker/wrapper stuff
      for recursive newtypes isn't very clever: we generate demand info but
      then don't properly exploit it.  
      
      This patch fixes the crash though.
      ca919ae0
  4. 13 Dec, 2007 2 commits
  5. 26 Oct, 2007 1 commit
  6. 16 Oct, 2007 1 commit
  7. 04 Sep, 2007 1 commit
  8. 03 Sep, 2007 1 commit
  9. 01 Sep, 2007 1 commit
  10. 16 Aug, 2007 1 commit
  11. 16 Jul, 2007 1 commit
  12. 23 May, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Improve the interaction of 'seq' and associated data types · 9670d664
      simonpj@microsoft.com authored
      Roman produced programs involving associated types that did not optimise well.
      His programs were something like this:
      
        data family T a
        data instance T Int = MkT Bool Char
      
        bar :: T Int -> Int
        bar t = t `seq` loop 0
      	where
      	  loop = ...
      
      You'd think that the `seq` should unbox 't' outside the loop, since
      a (T Int) is just a MkT pair.  
      
      The most robust way to make this happen is for the simplifier to understand
      a bit about type-family instances.   See 
      	Note [Improving seq]
      in Simplify.lhs.  We use FamInstEnv.topNormaliseType to do the interesting
      work.
      
      To make this happen I did a bit of refactoring to the simplifier
      monad.
      
      I'd previously done a very similar transformation in LiberateCase, but it
      was happening too late.  So this patch takes it out of LiberateCase as
      well as adding it to Simplify.
      
      
      9670d664
  13. 09 Feb, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Major improvement to SpecConstr · cac2aca1
      simonpj@microsoft.com authored
      This patch improves the SpecConstr pass, by 
        a) making it work with join points
        b) making it generate specialisations transitively
      
      As part of it, SpecConstr now carries a substitution with it, which
      runs over the whole program as it goes.  This turned out to be 
      a big win; simplified the implementation quite a bit.
      
      I have *disabled* the specialisation on lambdas; it's pretty fragile,
      and sometimes generates more and more specialisations. Something to
      come back to, perhaps.
      
      I rejigged the flag-handling a bit.  Now the specification of passes
      in DynFlags is a bit nicer; see
      	- optLevelFlags top-level data structure
      	- runWhen function
      	- CoreDoPasses constructor
      
      There are now command-line flags
      	-fspec-constr
      	-fliberate-case
      	-fspec-threshold=N
      which do the obvious thing.  -O2 switches on both spec-constr and liberate-case.
      You can use -fno-liberate-case, -fno-spec-constr after -O2 to switch them off again.
      
      The spec-threshold applies to both these transformations; default value 200 for now.
      
      
      
      
      cac2aca1
  14. 11 Jan, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Make the LiberateCase transformation understand associated types · 7aa3f524
      simonpj@microsoft.com authored
      Consider this FC program:
      	data family AT a :: *
      	data instance AT Int = T1 Int Int
      
      	f :: AT Int -> Int
      	f t = case t of DEFAULT -> <body>
      
      We'd like to replace the DEFAULT by a use of T1, so that if 
      we scrutinise t inside <body> we share the evaluation:
      
      	f t = case (t `cast` co) of T1 x y -> <body>
      
      I decided to do this as part of the liberate-case transformation,
      which is already trying to avoid redundant evals.  
      
      The new transformation requires knowledge of the family instance
      environment, so I had to extend ModGuts to carry the fam_inst_env,
      and put that envt into the liberate-case environment. 
      
      Otherwise it's all pretty straightforward.
      7aa3f524
  15. 18 May, 2006 1 commit
  16. 17 May, 2006 1 commit
  17. 07 Apr, 2006 1 commit
    • Simon Marlow's avatar
      Reorganisation of the source tree · 0065d5ab
      Simon Marlow authored
      Most of the other users of the fptools build system have migrated to
      Cabal, and with the move to darcs we can now flatten the source tree
      without losing history, so here goes.
      
      The main change is that the ghc/ subdir is gone, and most of what it
      contained is now at the top level.  The build system now makes no
      pretense at being multi-project, it is just the GHC build system.
      
      No doubt this will break many things, and there will be a period of
      instability while we fix the dependencies.  A straightforward build
      should work, but I haven't yet fixed binary/source distributions.
      Changes to the Building Guide will follow, too.
      0065d5ab
  18. 28 Jul, 2005 1 commit
  19. 19 Jul, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-07-19 16:44:50 by simonpj] · a7ecdf96
      simonpj authored
      WARNING: this is a big commit.  You might want 
      	to wait a few days before updating, in case I've 
      	broken something.
      
      	However, if any of the changes are what you wanted,
      	please check it out and test!
      
      This commit does three main things:
      
      1. A re-organisation of the way that GHC handles bindings in HsSyn.
         This has been a bit of a mess for quite a while.  The key new
         types are
      
      	-- Bindings for a let or where clause
      	data HsLocalBinds id
      	  = HsValBinds (HsValBinds id)
      	  | HsIPBinds  (HsIPBinds id)
      	  | EmptyLocalBinds
      
      	-- Value bindings (not implicit parameters)
      	data HsValBinds id
      	  = ValBindsIn  -- Before typechecking
      		(LHsBinds id) [LSig id]	-- Not dependency analysed
      					-- Recursive by default
      
      	  | ValBindsOut	-- After typechecking
      		[(RecFlag, LHsBinds id)]-- Dependency analysed
      
      2. Implement Mark Jones's idea of increasing polymoprhism
         by using type signatures to cut the strongly-connected components
         of a recursive group.  As a consequence, GHC no longer insists
         on the contexts of the type signatures of a recursive group
         being identical.
      
         This drove a significant change: the renamer no longer does dependency
         analysis.  Instead, it attaches a free-variable set to each binding,
         so that the type checker can do the dep anal.  Reason: the typechecker
         needs to do *two* analyses:
      	one to find the true mutually-recursive groups
      		(which we need so we can build the right CoreSyn)
      	one to find the groups in which to typecheck, taking
      		account of type signatures
      
      3. Implement non-ground SPECIALISE pragmas, as promised, and as
         requested by Remi and Ross.  Certainly, this should fix the 
         current problem with GHC, namely that if you have
      	g :: Eq a => a -> b -> b
         then you can now specialise thus
      	SPECIALISE g :: Int -> b -> b
          (This didn't use to work.)
      
         However, it goes further than that.  For example:
      	f :: (Eq a, Ix b) => a -> b -> b
         then you can make a partial specialisation
      	SPECIALISE f :: (Eq a) => a -> Int -> Int
      
          In principle, you can specialise f to *any* type that is
          "less polymorphic" (in the sense of subsumption) than f's 
          actual type.  Such as
      	SPECIALISE f :: Eq a => [a] -> Int -> Int
          But I haven't tested that.
      
          I implemented this by doing the specialisation in the typechecker
          and desugarer, rather than leaving around the strange SpecPragmaIds,
          for the specialiser to find.  Indeed, SpecPragmaIds have vanished 
          altogether (hooray).
      
          Pragmas in general are handled more tidily.  There's a new
          data type HsBinds.Prag, which lives in an AbsBinds, and carries
          pragma info from the typechecker to the desugarer.
      
      
      Smaller things
      
      - The loop in the renamer goes via RnExpr, instead of RnSource.
        (That makes it more like the type checker.)
      
      - I fixed the thing that was causing 'check_tc' warnings to be 
        emitted.
      a7ecdf96
  20. 19 May, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-05-19 11:15:40 by simonpj] · 4a587049
      simonpj authored
      Tune up the reporting of unused imports
      
      		Merge to STABLE
      	(I think the earlier change made it across)
      	(PS: the commit also does some trimming of
      	redundant imports.  If they don't merge, just
      	discard them.)
      
      My earlier fixes to the reporting of unused imports still missed
      some obscure cases, some of which are now fixed by this commit.
      I had to make the import-provenance data type yet richer, but in
      fact it has more sharing now, so it may be cheaper on space.
      
      There's still one infelicity. Consider
      		import M( x )
      		imoprt N( x )
      where the same underlying 'x' is involved in both cases.  Currently we
      don't report a redundant import, because dropping either import would
      change the qualified names in scope (M.x, N.x). But if the qualified
      names aren't used, the import is indeed redundant. Sadly we don't know
      that, because we only know what Names are used.  Left for the future!
      There's a comment in RnNames.warnDuplicateImports
      
      This commit also trims quite a few redundant imports disovered
      by the new setup.
      4a587049
  21. 28 Apr, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-04-28 10:09:41 by simonpj] · dd313897
      simonpj authored
      This big commit does several things at once (aeroplane hacking)
      which change the format of interface files.  
      
      	So you'll need to recompile your libraries!
      
      1. The "stupid theta" of a newtype declaration
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Retain the "stupid theta" in a newtype declaration.
      For some reason this was being discarded, and putting it
      back in meant changing TyCon and IfaceSyn slightly.
         
      
      2. Overlap flags travel with the instance
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Arrange that the ability to support overlap and incoherence
      is a property of the *instance declaration* rather than the
      module that imports the instance decl.  This allows a library
      writer to define overlapping instance decls without the
      library client having to know.  
      
      The implementation is that in an Instance we store the
      overlap flag, and preseve that across interface files
      
      
      3. Nuke the "instnce pool" and "rule pool"
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      A major tidy-up and simplification of the way that instances
      and rules are sucked in from interface files.  Up till now
      an instance decl has been held in a "pool" until its "gates" 
      (a set of Names) are in play, when the instance is typechecked
      and added to the InstEnv in the ExternalPackageState.  
      This is complicated and error-prone; it's easy to suck in 
      too few (and miss an instance) or too many (and thereby be
      forced to suck in its type constructors, etc).
      
      Now, as we load an instance from an interface files, we 
      put it straight in the InstEnv... but the Instance we put in
      the InstEnv has some Names (the "rough-match" names) that 
      can be used on lookup to say "this Instance can't match".
      The detailed dfun is only read lazily, and the rough-match
      thing meansn it is'nt poked on until it has a chance of
      being needed.
      
      This simply continues the successful idea for Ids, whereby
      they are loaded straightaway into the TypeEnv, but their
      TyThing is a lazy thunk, not poked on until the thing is looked
      up.
      
      Just the same idea applies to Rules.
      
      On the way, I made CoreRule and Instance into full-blown records
      with lots of info, with the same kind of key status as TyCon or 
      DataCon or Class.  And got rid of IdCoreRule altogether.   
      It's all much more solid and uniform, but it meant touching
      a *lot* of modules.
      
      
      4. Allow instance decls in hs-boot files
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Allowing instance decls in hs-boot files is jolly useful, becuase
      in a big mutually-recursive bunch of data types, you want to give
      the instances with the data type declarations.  To achieve this
      
      * The hs-boot file makes a provisional name for the dict-fun, something
        like $fx9.
      
      * When checking the "mother module", we check that the instance
        declarations line up (by type) and generate bindings for the 
        boot dfuns, such as
      	$fx9 = $f2
        where $f2 is the dfun generated by the mother module
      
      * In doing this I decided that it's cleaner to have DFunIds get their
        final External Name at birth.  To do that they need a stable OccName,
        so I have an integer-valued dfun-name-supply in the TcM monad.
        That keeps it simple.
      
      This feature is hardly tested yet.
      
      
      5. Tidy up tidying, and Iface file generation
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      main/TidyPgm now has two entry points:
      
        simpleTidyPgm is for hi-boot files, when typechecking only
        (not yet implemented), and potentially when compiling without -O.
        It ignores the bindings, and generates a nice small TypeEnv.
      
        optTidyPgm is the normal case: compiling with -O.  It generates a
        TypeEnv rich in IdInfo
      
      MkIface.mkIface now only generates a ModIface.  A separate
      procedure, MkIface.writeIfaceFile, writes the file out to disk.
      dd313897
  22. 18 Mar, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-03-18 13:37:27 by simonmar] · d1c1b7d0
      simonmar authored
      Flags cleanup.
      
      Basically the purpose of this commit is to move more of the compiler's
      global state into DynFlags, which is moving in the direction we need
      to go for the GHC API which can have multiple active sessions
      supported by a single GHC instance.
      
      Before:
      
      $ grep 'global_var' */*hs | wc -l
           78
      
      After:
      
      $ grep 'global_var' */*hs | wc -l
           27
      
      Well, it's an improvement.  Most of what's left won't really affect
      our ability to host multiple sessions.
      
      Lots of static flags have become dynamic flags (yay!).  Notably lots
      of flags that we used to think of as "driver" flags, like -I and -L,
      are now dynamic.  The most notable static flags left behind are the
      "way" flags, eg. -prof.  It would be nice to fix this, but it isn't
      urgent.
      
      On the way, lots of cleanup has happened.  Everything related to
      static and dynamic flags lives in StaticFlags and DynFlags
      respectively, and they share a common command-line parser library in
      CmdLineParser.  The flags related to modes (--makde, --interactive
      etc.) are now private to the front end: in fact private to Main
      itself, for now.
      d1c1b7d0
  23. 17 Mar, 2005 1 commit
  24. 09 Mar, 2005 1 commit
  25. 07 Mar, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-03-07 16:46:08 by simonpj] · 36d22a1c
      simonpj authored
      -----------------------------------------
             Fix a long-standing indirection-zapping bug
      	-----------------------------------------
      
      	Merge to STABLE
      
      Up to now we zap indirections as part of the occurence analyser.
      But this is bogus.  The indirection zapper does the following:
      
      	x_local = <expression>
      	...bindings...
      	x_exported = x_local
      
      where x_exported is exported, and x_local is not, then we
      replace it with this:
      
      	x_exported = <expression>
      	x_local = x_exported
      	...bindings...
      
      But this is plain wrong if x_exported has a RULE that mentions
      something (f, say) in ...bindings.., because 'f' will then die.
      
      After hacking a few solutions, I've eventually simply made the indirection
      zapping into a separate pass (which is cleaner anyway), which wraps the
      entire program back into a single Rec if the bad thing can happen.
      
      On the way I've made indirection-zapping work in Recs too, which wasn't the
      case before.
      
      * Move the zapper from OccurAnal into SimplCore
      * Tidy up the printing of pragmas (PprCore and friends)
      * Add a new function Rules.addRules
      * Merge rules in the indirection zapper (previously one set was discarded)
      36d22a1c
  26. 25 Feb, 2005 1 commit
  27. 18 Jan, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-01-18 12:18:11 by simonpj] · ac80e0de
      simonpj authored
      ------------------------
          Reorganisation of hi-boot files
        	------------------------
      
      The main point of this commit is to arrange that in the Compilation
      Manager's dependendency graph, hi-boot files are proper nodes. This
      is important to make sure that we compile everything in the right
      order.  It's a step towards hs-boot files.
      
      * The fundamental change is that CompManager.ModSummary has a new
        field, ms_boot :: IsBootInterface
      
        I also tided up CompManager a bit.  No change to the Basic Plan.
      
        ModSummary is now exported abstractly from CompManager (was concrete)
      
      * Hi-boot files now have import declarations.  The idea is they are
        compulsory, so that the dependency analyser can find them
      
      * I changed an invariant: the Compilation Manager used to ensure that
        hscMain was given a HomePackageTable only for the modules 'below' the
        one being compiled.  This was really only important for instances and
        rules, and it was a bit inconvenient.  So I moved the filter to the
        compiler itself: see HscTypes.hptInstances and hptRules.
      
      * Module Packages.hs now defines
          data PackageIdH
          = HomePackage 		-- The "home" package is the package
       				-- curently being compiled
          | ExtPackage PackageId	-- An "external" package is any other package
      
         It was just a Maybe type before, so this makes it a bit clearer.
      
      * I tried to add a bit better location info to the IfM monad, so that
        errors in interfaces come with a slightly more helpful error message.
        See the if_loc field in TcRnTypes --- and follow-on consequences
      
      * Changed Either to Maybes.MaybeErr in a couple of places (more perspicuous)
      ac80e0de
  28. 27 Dec, 2004 1 commit
  29. 24 Dec, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-12-24 16:14:36 by simonpj] · 339d5220
      simonpj authored
      ---------------------------
                Refactor the simplifier
        	---------------------------
      
      Driven by a GADT bug, I have refactored the simpifier, and the way GHC
      treats substitutions.  I hope I have gotten it right.  Be cautious about updating.
      
      * coreSyn/Subst.lhs has gone
      
      * coreSyn/CoreSubst replaces it, except that it's quite a bit simpler
      
      * simplCore/SimplEnv is added, and contains the simplifier-specific substitution
        stuff
      
      Previously Subst was trying to be all things to all men, and that was making
      it Too Complicated.
      
      There may be a little more code now, but it's much easier to understand.
      339d5220
  30. 26 Nov, 2004 1 commit
    • simonmar's avatar
      [project @ 2004-11-26 16:19:45 by simonmar] · ef5b4b14
      simonmar authored
      Further integration with the new package story.  GHC now supports
      pretty much everything in the package proposal.
      
        - GHC now works in terms of PackageIds (<pkg>-<version>) rather than
          just package names.  You can still specify package names without
          versions on the command line, as long as the name is unambiguous.
      
        - GHC understands hidden/exposed modules in a package, and will refuse
          to import a hidden module.  Also, the hidden/eposed status of packages
          is taken into account.
      
        - I had to remove the old package syntax from ghc-pkg, backwards
          compatibility isn't really practical.
      
        - All the package.conf.in files have been rewritten in the new syntax,
          and contain a complete list of modules in the package.  I've set all
          the versions to 1.0 for now - please check your package(s) and fix the
          version number & other info appropriately.
      
        - New options:
      
      	-hide-package P    sets the expose flag on package P to False
      	-ignore-package P  unregisters P for this compilation
      
      	For comparison, -package P sets the expose flag on package P
              to True, and also causes P to be linked in eagerly.
      
              -package-name is no longer officially supported.  Unofficially, it's
      	a synonym for -ignore-package, which has more or less the same effect
      	as -package-name used to.
      
      	Note that a package may be hidden and yet still be linked into
      	the program, by virtue of being a dependency of some other package.
      	To completely remove a package from the compiler's internal database,
              use -ignore-package.
      
      	The compiler will complain if any two packages in the
              transitive closure of exposed packages contain the same
              module.
      
      	You *must* use -ignore-package P when compiling modules for
              package P, if package P (or an older version of P) is already
              registered.  The compiler will helpfully complain if you don't.
      	The fptools build system does this.
      
         - Note: the Cabal library won't work yet.  It still thinks GHC uses
           the old package config syntax.
      
      Internal changes/cleanups:
      
         - The ModuleName type has gone away.  Modules are now just (a
           newtype of) FastStrings, and don't contain any package information.
           All the package-related knowledge is in DynFlags, which is passed
           down to where it is needed.
      
         - DynFlags manipulation has been cleaned up somewhat: there are no
           global variables holding DynFlags any more, instead the DynFlags
           are passed around properly.
      
         - There are a few less global variables in GHC.  Lots more are
           scheduled for removal.
      
         - -i is now a dynamic flag, as are all the package-related flags (but
           using them in {-# OPTIONS #-} is Officially Not Recommended).
      
         - make -j now appears to work under fptools/libraries/.  Probably
           wouldn't take much to get it working for a whole build.
      ef5b4b14
  31. 25 Nov, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-11-25 11:36:34 by simonpj] · 1f7da302
      simonpj authored
      ------------------------------------------
      	Keep-alive set and Template Haskell quotes
      	------------------------------------------
      
      a) Template Haskell quotes should be able to mention top-leve
         things without resorting to lifting.  Example
      
      	module Foo( foo ) where
      	  f x = x
      	  foo = [| f 4 |]
      
         Here the reference to 'f' is ok; no need to 'lift' it.
         The relevant changes are in TcExpr.tcId
      
      b) However, we must take care not to discard the binding for f,
         so we add it to the 'keep-alive' set for the module.  I've
         now made this into (another) mutable bucket, tcg_keep, 
         in the TcGblEnv
      
      c) That in turn led me to look at the handling of orphan rules;
         as a result I made IdCoreRule into its own data type, which
         has simle but non-local ramifications
      1f7da302
  32. 30 Sep, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-09-30 10:35:15 by simonpj] · 23f40f0e
      simonpj authored
      ------------------------------------
      	Add Generalised Algebraic Data Types
      	------------------------------------
      
      This rather big commit adds support for GADTs.  For example,
      
          data Term a where
       	  Lit :: Int -> Term Int
      	  App :: Term (a->b) -> Term a -> Term b
      	  If  :: Term Bool -> Term a -> Term a
      	  ..etc..
      
          eval :: Term a -> a
          eval (Lit i) = i
          eval (App a b) = eval a (eval b)
          eval (If p q r) | eval p    = eval q
          		    | otherwise = eval r
      
      
      Lots and lots of of related changes throughout the compiler to make
      this fit nicely.
      
      One important change, only loosely related to GADTs, is that skolem
      constants in the typechecker are genuinely immutable and constant, so
      we often get better error messages from the type checker.  See
      TcType.TcTyVarDetails.
      
      There's a new module types/Unify.lhs, which has purely-functional
      unification and matching for Type. This is used both in the typechecker
      (for type refinement of GADTs) and in Core Lint (also for type refinement).
      23f40f0e
  33. 21 Apr, 2004 2 commits
    • simonpj's avatar
      [project @ 2004-04-21 12:45:54 by simonpj] · 711ede5f
      simonpj authored
      Do a much better job of slurping RULES.  
      
      Now that stuff is slurped in lazily, as the simplifier pokes on it,
      we may not get the rules as early as we might wish.  In the current
      HEAD, no new rules are slurped in after the beginning of SimplCore,
      and that means we permanently miss many rules.
      
      This commit arranges that every time round the simplifier loop we
      slurp in any new rules, and put them into the in-scope set, where the
      simplifier can find them.
      
      It's still possible that a rule might be slurped in a little later than
      in earlier versions of GHC, leading to more simplifier iterations,
      but let's see if that turns out to be a problem in practice.
      711ede5f
    • simonpj's avatar
      [project @ 2004-04-21 12:36:24 by simonpj] · e791a226
      simonpj authored
      Comments only
      e791a226
  34. 02 Apr, 2004 1 commit
  35. 30 Dec, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-12-30 16:29:17 by simonpj] · f714e6b6
      simonpj authored
      ----------------------------
              Re-do kind inference (again)
      	----------------------------
      
         [WARNING: interface file binary representation has
         (as usual) changed slightly; recompile your libraries!]
      
      Inspired by the lambda-cube, for some time GHC has used
      	type Kind = Type
      That is, kinds were represented by the same data type as types.
      
      But GHC also supports unboxed types and unboxed tuples, and these
      complicate the kind system by requiring a sub-kind relationship.
      Notably, an unboxed tuple is acceptable as the *result* of a
      function but not as an *argument*.  So we have the following setup:
      
      		 ?
      		/ \
      	       /   \
      	      ??   (#)
      	     /  \
                  *   #
      
      where	*    [LiftedTypeKind]   means a lifted type
      	#    [UnliftedTypeKind] means an unlifted type
      	(#)  [UbxTupleKind]     means unboxed tuple
      	??   [ArgTypeKind]      is the lub of *,#
      	?    [OpenTypeKind]	means any type at all
      
      In particular:
      
        error :: forall a:?. String -> a
        (->)  :: ?? -> ? -> *
        (\(x::t) -> ...)	Here t::?? (i.e. not unboxed tuple)
      
      All this has beome rather difficult to accommodate with Kind=Type, so this
      commit splits the two.
      
        * Kind is a distinct type, defined in types/Kind.lhs
      
        * IfaceType.IfaceKind disappears: we just re-use Kind.Kind
      
        * TcUnify.unifyKind is a distinct unifier for kinds
      
        * TyCon no longer needs KindCon and SuperKindCon variants
      
        * TcUnify.zapExpectedType takes an expected Kind now, so that
          in TcPat.tcMonoPatBndr we can express that the bound variable
          must have an argTypeKind (??).
      
      The big change is really that kind inference is much more systematic and
      well behaved.  In particular, a kind variable can unify only with a
      "simple kind", which is built from * and (->).  This deals neatly
      with awkward questions about how we can combine sub-kinding with type
      inference.
      
      Lots of small consequential changes, especially to the kind-checking
      plumbing in TcTyClsDecls.  (We played a bit fast and loose before, and
      now we have to be more honest, in particular about how kind inference
      works for type synonyms.  They can have kinds like (* -> #), so
      
      This cures two long-standing SourceForge bugs
      
      * 753777 (tcfail115.hs), which used erroneously to pass,
        but crashed in the code generator
            type T a = Int -> (# Int, Int #)
            f :: T a -> T a
            f t = \x -> case t x of r -> r
      
      * 753780 (tc167.hs), which used erroneously to fail
            f :: (->) Int# Int#
      
      
      Still, the result is not entirely satisfactory.  In particular
      
      * The error message from tcfail115 is pretty obscure
      
      * SourceForge bug 807249 (Instance match failure on openTypeKind)
        is not fixed.  Alas.
      f714e6b6
  36. 29 Oct, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-10-29 18:14:27 by simonpj] · 7c3d4a1f
      simonpj authored
      Fix a bad consequence of the new story for the generic toT/fromT functions
      derived from data types declarations. The problem was that they were being
      generated and then discarded by the simplifier, because there was nothing
      keeping them alive.
      
      This commit
        * Adds a field tcg_keep to the TcGblEnv, which records things
          to be kept alive;
      
        * Makes the desugarer pin the keep-alive flag on each binding
          (it's actually a call to setIdLocalExported)
      
        * Removes that job from updateBinders in SimplCore
      
      
      It's somewhat tiresome, but not really difficult.
      7c3d4a1f
  37. 13 Oct, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-10-13 10:43:02 by simonpj] · 7e7c11b2
      simonpj authored
      Deal corectly with rules for Ids defined in this module,
      even when they are imported (as orphans) from other modules.
      
      The epicentre for this stuff is SimplCore.
      7e7c11b2
  38. 10 Oct, 2003 1 commit