1. 21 Feb, 2003 1 commit
    • 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
  2. 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
  3. 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
  4. 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
  5. 06 Sep, 2002 1 commit
  6. 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
  7. 01 Apr, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-04-01 08:23:30 by simonpj] · 9003a18c
      simonpj authored
      ------------------------------------
      	Change the treatment of the stupid
      	   context on data constructors
      	-----------------------------------
      
      Data types can have a context:
      
      	data (Eq a, Ord b) => T a b = T1 a b | T2 a
      
      and that makes the constructors have a context too
      (notice that T2's context is "thinned"):
      
      	T1 :: (Eq a, Ord b) => a -> b -> T a b
      	T2 :: (Eq a) => a -> T a b
      
      Furthermore, this context pops up when pattern matching
      (though GHC hasn't implemented this, but it is in H98, and
      I've fixed GHC so that it now does):
      
      	f (T2 x) = x
      gets inferred type
      	f :: Eq a => T a b -> a
      
      I say the context is "stupid" because the dictionaries passed
      are immediately discarded -- they do nothing and have no benefit.
      It's a flaw in the language.
      
      Up to now I have put this stupid context into the type of
      the "wrapper" constructors functions, T1 and T2, but that turned
      out to be jolly inconvenient for generics, and record update, and
      other functions that build values of type T (because they don't
      have suitable dictionaries available).
      
      So now I've taken the stupid context out.  I simply deal with
      it separately in the type checker on occurrences of a constructor,
      either in an expression or in a pattern.
      
      To this end
      
      * Lots of changes in DataCon, MkId
      
      * New function Inst.tcInstDataCon to instantiate a data constructor
      
      
      
      I also took the opportunity to
      
      * Rename
      	dataConId --> dataConWorkId
        for consistency.
      
      * Tidied up MkId.rebuildConArgs quite a bit, and renamed it
      	mkReboxingAlt
      
      * Add function DataCon.dataConExistentialTyVars, with the obvious meaning
      9003a18c
  8. 13 Feb, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-02-13 15:19:17 by simonpj] · 711e4d7a
      simonpj authored
      ----------------------------------
      	Do the Right Thing for TyCons where we
      	can't see all their constructors.
      	----------------------------------
      
      Inside a TyCon, three things can happen
      
      1. GHC knows all the constructors, and has them to hand.
         (Nowadays, there may be zero constructors.)
      
      2. GHC knows all the constructors, but has declined to slurp
         them all in, to avoid sucking in more declarations than
         necessary.  All we remember is the number of constructors,
         so we can get the return convention right.
      
      3. GHC doesn't know anything. This happens *only* for decls
         coming from .hi-boot files, where the programmer declines to
         supply a representation.
      
      Until now, these three cases have been conflated together.  Matters
      are worse now that a TyCon really can have zero constructors.  In
      fact, by confusing (3) with (1) we can actually generate bogus code.
      
      With this commit, the dataCons field of a TyCon is of type:
      
      data DataConDetails datacon
        = DataCons [datacon]	-- Its data constructors, with fully polymorphic types
      			-- A type can have zero constructors
      
        | Unknown		-- We're importing this data type from an hi-boot file
      			-- and we don't know what its constructors are
      
        | HasCons Int		-- In a quest for compilation speed we have imported
      			-- only the number of constructors (to get return
      			-- conventions right) but not the constructors themselves
      
      This says exactly what is going on.  There are lots of consequential small
      changes.
      711e4d7a
  9. 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
  10. 26 Nov, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-11-26 09:20:25 by simonpj] · 5e3f005d
      simonpj authored
      ----------------------
      	Implement Rank-N types
      	----------------------
      
      This commit implements the full glory of Rank-N types, using
      the Odersky/Laufer approach described in their paper
      	"Putting type annotations to work"
      
      In fact, I've had to adapt their approach to deal with the
      full glory of Haskell (including pattern matching, and the
      scoped-type-variable extension).  However, the result is:
      
      * There is no restriction to rank-2 types.  You can nest forall's
        as deep as you like in a type.  For example, you can write a type
        like
      	p :: ((forall a. Eq a => a->a) -> Int) -> Int
        This is a rank-3 type, illegal in GHC 5.02
      
      * When matching types, GHC uses the cunning Odersky/Laufer coercion
        rules.  For example, suppose we have
      	q :: (forall c. Ord c => c->c) -> Int
        Then, is this well typed?
      	x :: Int
      	x = p q
        Yes, it is, but GHC has to generate the right coercion.  Here's
        what it looks like with all the big lambdas and dictionaries put in:
      
      	x = p (\ f :: (forall a. Eq a => a->a) ->
      		 q (/\c \d::Ord c -> f c (eqFromOrd d)))
      
        where eqFromOrd selects the Eq superclass dictionary from the Ord
        dicationary:		eqFromOrd :: Ord a -> Eq a
      
      
      * You can use polymorphic types in pattern type signatures.  For
        example:
      
      	f (g :: forall a. a->a) = (g 'c', g True)
      
        (Previously, pattern type signatures had to be monotypes.)
      
      * The basic rule for using rank-N types is that you must specify
        a type signature for every binder that you want to have a type
        scheme (as opposed to a plain monotype) as its type.
      
        However, you don't need to give the type signature on the
        binder (as I did above in the defn for f).  You can give it
        in a separate type signature, thus:
      
      	f :: (forall a. a->a) -> (Char,Bool)
      	f g = (g 'c', g True)
      
        GHC will push the external type signature inwards, and use
        that information to decorate the binders as it comes across them.
        I don't have a *precise* specification of this process, but I
        think it is obvious enough in practice.
      
      * In a type synonym you can use rank-N types too.  For example,
        you can write
      
      	type IdFun = forall a. a->a
      
      	f :: IdFun -> (Char,Bool)
      	f g = (g 'c', g True)
      
        As always, type synonyms must always occur saturated; GHC
        expands them before it does anything else.  (Still, GHC goes
        to some trouble to keep them unexpanded in error message.)
      
      
      The main plan is as before.  The main typechecker for expressions,
      tcExpr, takes an "expected type" as its argument.  This greatly
      improves error messages.  The new feature is that when this
      "expected type" (going down) meets an "actual type" (coming up)
      we use the new subsumption function
      	TcUnify.tcSub
      which checks that the actual type can be coerced into the
      expected type (and produces a coercion function to demonstrate).
      
      The main new chunk of code is TcUnify.tcSub.  The unifier itself
      is unchanged, but it has moved from TcMType into TcUnify.  Also
      checkSigTyVars has moved from TcMonoType into TcUnify.
      Result: the new module, TcUnify, contains all stuff relevant
      to subsumption and unification.
      
      Unfortunately, there is now an inevitable loop between TcUnify
      and TcSimplify, but that's just too bad (a simple TcUnify.hi-boot
      file).
      
      
      All of this doesn't come entirely for free.  Here's the typechecker
      line count (INCLUDING comments)
      	Before	16,551
      	After	17,116
      5e3f005d
  11. 06 Sep, 2001 1 commit
  12. 28 Aug, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-08-28 10:06:29 by simonpj] · b0604aad
      simonpj authored
      ----------------------------------------
      	Make isFFIArgumentTy understand newtypes
      	----------------------------------------
      
      This fixes the bug Manuel reported:
      
      	newtype T = T (Ptr T)
      	foreign import ccall foo :: T -> IO (Ptr T)
      
        test.hs:6:
            Unacceptable argument type in foreign declaration: T
      
      
      On the way, I moved isFFIArgumentTy and friends out of TysWiredIn,
      where they didn't really belong, into TcType.  That in turn force
      me to move isStrictType, and isPrimitiveType.
      b0604aad
  13. 23 Jul, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-07-23 10:54:46 by simonpj] · f6cd95ff
      simonpj authored
      ---------------------------------
      	Switch to the new demand analyser
      	---------------------------------
      
      This commit makes the new demand analyser the main beast,
      with the old strictness analyser as a backup.  When
      DEBUG is on, the old strictness analyser is run too, and the
      results compared.
      
      WARNING: this isn't thorougly tested yet, so expect glitches.
      Delay updating for a few days if the HEAD is mission critical
      for you.
      
      But do try it out.  I'm away for 2.5 weeks from Thursday, so
      it would be good to shake out any glaring bugs before then.
      f6cd95ff
  14. 25 Jun, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-06-25 08:09:57 by simonpj] · d069cec2
      simonpj authored
      ----------------
      	Squash newtypes
      	----------------
      
      This commit squashes newtypes and their coerces, from the typechecker
      onwards.  The original idea was that the coerces would not get in the
      way of optimising transformations, but despite much effort they continue
      to do so.   There's no very good reason to retain newtype information
      beyond the typechecker, so now we don't.
      
      Main points:
      
      * The post-typechecker suite of Type-manipulating functions is in
      types/Type.lhs, as before.   But now there's a new suite in types/TcType.lhs.
      The difference is that in the former, newtype are transparent, while in
      the latter they are opaque.  The typechecker should only import TcType,
      not Type.
      
      * The operations in TcType are all non-monadic, and most of them start with
      "tc" (e.g. tcSplitTyConApp).  All the monadic operations (used exclusively
      by the typechecker) are in a new module, typecheck/TcMType.lhs
      
      * I've grouped newtypes with predicate types, thus:
      	data Type = TyVarTy Tyvar | ....
      		  | SourceTy SourceType
      
      	data SourceType = NType TyCon [Type]
      			| ClassP Class [Type]
      			| IParam Type
      
      [SourceType was called PredType.]  This is a little wierd in some ways,
      because NTypes can't occur in qualified types.   However, the idea is that
      a SourceType is a type that is opaque to the type checker, but transparent
      to the rest of the compiler, and newtypes fit that as do implicit parameters
      and dictionaries.
      
      * Recursive newtypes still retain their coreces, exactly as before. If
      they were transparent we'd get a recursive type, and that would make
      various bits of the compiler diverge (e.g. things which do type comparison).
      
      * I've removed types/Unify.lhs (non-monadic type unifier and matcher),
      merging it into TcType.
      
      Ditto typecheck/TcUnify.lhs (monadic unifier), merging it into TcMType.
      d069cec2
  15. 22 May, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-05-22 13:43:14 by simonpj] · f16228e4
      simonpj authored
      -------------------------------------------
      	Towards generalising 'foreign' declarations
      	-------------------------------------------
      
      This is a first step towards generalising 'foreign' declarations to
      handle langauges other than C.  Quite a lot of files are touched,
      but nothing has really changed.  Everything should work exactly as
      before.
      
      	But please be on your guard for ccall-related bugs.
      
      Main things
      
      Basic data types: ForeignCall.lhs
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * Remove absCSyn/CallConv.lhs
      
      * Add prelude/ForeignCall.lhs.  This defines the ForeignCall
        type and its variants
      
      * Define ForeignCall.Safety to say whether a call is unsafe
        or not (was just a boolean).  Lots of consequential chuffing.
      
      * Remove all CCall stuff from PrimOp, and put it in ForeignCall
      
      
      Take CCallOp out of the PrimOp type (where it was always a glitch)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * Add IdInfo.FCallId variant to the type IdInfo.GlobalIdDetails,
      	along with predicates Id.isFCallId, Id.isFCallId_maybe
      
      * Add StgSyn.StgOp, to sum PrimOp with FCallOp, because it
        *is* useful to sum them together in Stg and AbsC land.  If
        nothing else, it minimises changes.
      
      
      Also generally rename "CCall" stuff to "FCall" where it's generic
      to all foreign calls.
      f16228e4
  16. 18 May, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-05-18 08:46:18 by simonpj] · b4775e5e
      simonpj authored
      -----------------------------
      	Get unbox-strict-fields right
      	-----------------------------
      
      The problem was that when a library was compiled *without* -funbox-strict-fields,
      and the main program was compiled *with* that flag, we were wrongly treating
      the fields of imported data types as unboxed.
      
      To fix this I added an extra constructor to StrictnessMark to express whether
      the "!" annotation came from an interface file (don't fiddle) or a source
      file (decide whether to unbox).
      
      On the way I tided things up:
      
      * StrictnessMark moves to Demand.lhs, and doesn't have the extra DataCon
        fields that kept it in DataCon before.
      
      * HsDecls.BangType has one constructor, not three, with a StrictnessMark field.
      
      * DataCon keeps track of its strictness signature (dcRepStrictness), but not
        its "user strict marks" (which were never used)
      
      * All the functions, like getUniquesDs, that used to take an Int saying how
        many uniques to allocate, now return an infinite list. This saves arguments
        and hassle.  But it involved touching quite a few files.
      
      * rebuildConArgs takes a list of Uniques to use as its unique supply.  This
        means I could combine DsUtils.rebuildConArgs with MkId.rebuildConArgs
        (hooray; the main point of the previous change)
      
      
      I also tidied up one or two error messages
      b4775e5e
  17. 04 May, 2001 1 commit
  18. 13 Apr, 2001 1 commit
    • panne's avatar
      [project @ 2001-04-13 21:37:42 by panne] · 21c60059
      panne authored
      First steps toward a better typing of f.e.d. and friends: Make FunPtr
      a fully-fledged data type, not a renaming for Ptr. This is necessary,
      because the FFI "looks through" newtypes, which we don't want in this
      case.
      21c60059
  19. 13 Mar, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-03-13 14:58:25 by simonpj] · 788faebb
      simonpj authored
      ----------------
      	Nuke ClassContext
      	----------------
      
      This commit tidies up a long-standing inconsistency in GHC.
      The context of a class or instance decl used to be restricted
      to predicates of the form
      	C t1 .. tn
      with
      	type ClassContext = [(Class,[Type])]
      
      but everywhere else in the compiler we used
      
      	type ThetaType = [PredType]
      where PredType can be any sort of constraint (= predicate).
      
      The inconsistency actually led to a crash, when compiling
      	class (?x::Int) => C a where {}
      
      I've tidied all this up by nuking ClassContext altogether, and using
      PredType throughout.  Lots of modified files, but all in
      more-or-less trivial ways.
      
      I've also added a check that the context of a class or instance
      decl doesn't include a non-inheritable predicate like (?x::Int).
      
      Other things
      
       * rename constructor 'Class' from type TypeRep.Pred to 'ClassP'
         (makes it easier to grep for)
      
       * rename constructor HsPClass  => HsClassP
      		      HsPIParam => HsIParam
      788faebb
  20. 11 Jan, 2001 2 commits
    • qrczak's avatar
      [project @ 2001-01-11 22:04:39 by qrczak] · e19816a8
      qrczak authored
      Allow Ptr in foreign dynamic declarations
      e19816a8
    • simonmar's avatar
      [project @ 2001-01-11 17:25:56 by simonmar] · efa88123
      simonmar authored
      Re-organisation of ghc/lib/std and hslibs/lang
      ----------------------------------------------
      
      In brief: move deprecated features out of ghc/lib/std and into
      hslibs/lang, move new FFI libraries into ghc/lib/std and start
      using them.
      
      - foreign import may now return an unboxed type (this was
        advertised to work before, but in fact didn't).  Subsequent
        cleanups in PrelInt/PrelWord.
      
      - Ptr is now defined in ghc/lib/std/PrelPtr.lhs.  Ptr is no
        longer a newtype of Addr, it is defined directly in terms of
        Addr#.
      
      - PrelAddr has disappeared from ghc/lib/std, all uses of Addr in
        ghc/lib/std have been replaced with Ptr.  The definitions of
        Addr has been moved to hslibs/lang/Addr.lhs, as has
        lots of other Addr-related stuff.
      
      - ForeignObj has been removed from ghc/lib/std, and replaced with
        ForeignPtr.  The definition of ForeignObj has been moved to
        hslibs/lang/ForeignObj.lhs.
      
      - Most of the new FFI has been moved into ghc/lib/std in the form
        of modules PrelMarshalAlloc, PrelCString, PrelCError,
        PrelMarshalError, PrelMarshalArray, PrelMarshalUtils,
        PrelCTypes, PrelCTypesISO, and PrelStorable.  The corresponding
        modules in hslibs/lang simply re-export the contents of these
        modules.
      
      - PrelPosixTypes defines a few POSIX types (CMode == mode_t,
        etc.)
      
      - PrelCError changed to access errno using foreign label and peek
        (the POSIX book I have says that errno is guaranteed to be an
        extern int, so this should be OK until I get around to making
        errno thread-safe).
      
      - Hacked the macros that generate the code for CTypes and
        CTypesISO to generate much less code
        (ghc/lib/std/cbits/CTypes.h).
      
      - RtsAPI is now a bit more honest when it comes to building heap
        objects (it uses the correct constructors).
      
      - the Bits class and related stuff has been moved to ghc/lib/std
        (it was simpler this way).
      
      - Directory and System have been converted to use the new FFI.
      efa88123
  21. 03 Jan, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-01-03 11:18:51 by simonmar] · 20d387c4
      simonmar authored
      s/boxed/lifted/
      
      The typechecker's notion of "boxed" versus "unboxed" kind should
      really have been "unlifted" versus "lifted" instead.  It is illegal to
      unify an unlifted (but boxed) type with a polymorphic type variable,
      since an unlifted/boxed type is always assumed to be a pointer to the
      object itself, never a thunk or indirection.
      
      This commit removes isUnboxedType, and renames a bunch of things that
      were previously boxed/unboxed to unlifted/lifted.
      20d387c4
  22. 11 Dec, 2000 1 commit
  23. 24 Nov, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-11-24 17:02:01 by simonpj] · 83eef621
      simonpj authored
      1. Make the new version machinery work.
         I think it does now!
      
      2. Consequence of (1): Move the generation of
         default method names to one place (namely
         in RdrHsSyn.mkClassOpSigDM
      
      3. Major clean up on HsDecls.TyClDecl
         These big constructors should have been records
         ages ago, and they are now.  At last.
      83eef621
  24. 21 Nov, 2000 1 commit
  25. 20 Nov, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-11-20 14:48:52 by simonpj] · c271b647
      simonpj authored
      When renaming, typechecking an expression from the user
      interface, we may suck in declarations from interface
      files (e.g. the Prelude).  This commit takes account of that.
      
      To do so, I did some significant restructuring in TcModule,
      with consequential changes and tidy ups elsewhere in the type
      checker.  I think there should be fewer lines in total than before.
      c271b647
  26. 10 Nov, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-11-10 15:12:50 by simonpj] · f23ba2b2
      simonpj authored
      1.	Outputable.PprStyle now carries a bit more information
      	In particular, the printing style tells whether to print
      	a name in unqualified form.  This used to be embedded in
      	a Name, but since Names now outlive a single compilation unit,
      	that's no longer appropriate.
      
      	So now the print-unqualified predicate is passed in the printing
      	style, not embedded in the Name.
      
         2.	I tidied up HscMain a little.  Many of the showPass messages
      	have migraged into the repective pass drivers
      f23ba2b2
  27. 06 Nov, 2000 1 commit
  28. 25 Oct, 2000 1 commit
  29. 24 Oct, 2000 2 commits
  30. 17 Oct, 2000 1 commit
  31. 12 Oct, 2000 3 commits
  32. 03 Oct, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-10-03 08:43:00 by simonpj] · 710e2074
      simonpj authored
      --------------------------------------
      	Adding generics		SLPJ Oct 2000
      	--------------------------------------
      
      This big commit adds Hinze/PJ-style generic class definitions, based
      on work by Andrei Serjantov.  For example:
      
        class Bin a where
          toBin   :: a -> [Int]
          fromBin :: [Int] -> (a, [Int])
      
          toBin {| Unit |}    Unit	  = []
          toBin {| a :+: b |} (Inl x)   = 0 : toBin x
          toBin {| a :+: b |} (Inr y)   = 1 : toBin y
          toBin {| a :*: b |} (x :*: y) = toBin x ++ toBin y
      
      
          fromBin {| Unit |}    bs      = (Unit, bs)
          fromBin {| a :+: b |} (0:bs)  = (Inl x, bs')    where (x,bs') = fromBin bs
          fromBin {| a :+: b |} (1:bs)  = (Inr y, bs')    where (y,bs') = fromBin bs
          fromBin {| a :*: b |} bs  	  = (x :*: y, bs'') where (x,bs' ) = fromBin bs
      							  (y,bs'') = fromBin bs'
      
      Now we can say simply
      
        instance Bin a => Bin [a]
      
      and the compiler will derive the appropriate code automatically.
      
      		(About 9k lines of diffs.  Ha!)
      
      
      Generic related things
      ~~~~~~~~~~~~~~~~~~~~~~
      
      * basicTypes/BasicTypes: The EP type (embedding-projection pairs)
      
      * types/TyCon:
      	An extra field in an algebraic tycon (genInfo)
      
      * types/Class, and hsSyn/HsBinds:
      	Each class op (or ClassOpSig) carries information about whether
      	it  	a) has no default method
      		b) has a polymorphic default method
      		c) has a generic default method
      	There's a new data type for this: Class.DefMeth
      
      * types/Generics:
      	A new module containing good chunk of the generic-related code
      	It has a .hi-boot file (alas).
      
      * typecheck/TcInstDcls, typecheck/TcClassDcl:
      	Most of the rest of the generics-related code
      
      * hsSyn/HsTypes:
      	New infix type form to allow types of the form
      		data a :+: b = Inl a | Inr b
      
      * parser/Parser.y, Lex.lhs, rename/ParseIface.y:
      	Deal with the new syntax
      
      * prelude/TysPrim, TysWiredIn:
      	Need to generate generic stuff for the wired-in TyCons
      
      * rename/RnSource RnBinds:
      	A rather gruesome hack to deal with scoping of type variables
      	from a generic patterns.  Details commented in the ClassDecl
      	case of RnSource.rnDecl.
      
      	Of course, there are many minor renamer consequences of the
      	other changes above.
      
      * lib/std/PrelBase.lhs
      	Data type declarations for Unit, :+:, :*:
      
      
      Slightly unrelated housekeeping
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * hsSyn/HsDecls:
      	ClassDecls now carry the Names for their implied declarations
      	(superclass selectors, tycon, etc) in a list, rather than
      	laid out one by one.  This simplifies code between the parser
      	and the type checker.
      
      * prelude/PrelNames, TysWiredIn:
      	All the RdrNames are now together in PrelNames.
      
      * utils/ListSetOps:
      	Add finite mappings based on equality and association lists (Assoc a b)
      	Move stuff from List.lhs that is related
      710e2074
  33. 28 Sep, 2000 1 commit
    • simonpj's avatar
      [project @ 2000-09-28 13:04:14 by simonpj] · 861e836e
      simonpj authored
      ------------------------------------
      	   Mainly PredTypes (28 Sept 00)
      	------------------------------------
      
      Three things in this commit:
      
      	1.  Main thing: tidy up PredTypes
      	2.  Move all Keys into PrelNames
      	3.  Check for unboxed tuples in function args
      
      1. Tidy up PredTypes
      ~~~~~~~~~~~~~~~~~~~~
      The main thing in this commit is to modify the representation of Types
      so that they are a (much) better for the qualified-type world.  This
      should simplify Jeff's life as he proceeds with implicit parameters
      and functional dependencies.  In particular, PredType, introduced by
      Jeff, is now blessed and dignified with a place in TypeRep.lhs:
      
      	data PredType  = Class  Class [Type]
      		       | IParam Name  Type
      
      Consider these examples:
      	f :: (Eq a) => a -> Int
      	g :: (?x :: Int -> Int) => a -> Int
      	h :: (r\l) => {r} => {l::Int | r}
      
      Here the "Eq a" and "?x :: Int -> Int" and "r\l" are all called
      *predicates*, and are represented by a PredType.  (We don't support
      TREX records yet, but the setup is designed to expand to allow them.)
      
      In addition, Type gains an extra constructor:
      
      	data Type = .... | PredTy PredType
      
      so that PredType is injected directly into Type.  So the type
      	p => t
      is represented by
      	PredType p `FunTy` t
      
      I have deleted the hackish IPNote stuff; predicates are dealt with entirely
      through PredTys, not through NoteTy at all.
      
      
      2.  Move Keys into PrelNames
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      This is just a housekeeping operation. I've moved all the pre-assigned Uniques
      (aka Keys) from Unique.lhs into PrelNames.lhs.  I've also moved knowKeyRdrNames
      from PrelInfo down into PrelNames.  This localises in PrelNames lots of stuff
      about predefined names.  Previously one had to alter three files to add one,
      now only one.
      
      3.  Unboxed tuples
      ~~~~~~~~~~~~~~~~~~
      Add a static check for unboxed tuple arguments.  E.g.
      	data T = T (# Int, Int #)
      is illegal
      861e836e
  34. 24 Aug, 2000 1 commit
  35. 24 Jul, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-07-24 14:29:55 by simonmar] · 1da7b45d
      simonmar authored
      Some changes to the way FFI decls are handled:
      
        - a foreign export dynamic which returns a newtype of
          an Addr now works correctly.  Similarly for foreign label.
      
        - unlifted types are not allowed in the arguments of a foreign
          export.  Previously we generated incorrect code for these cases.
      
      Newtypes in FFI declarations now work everywhere they should, as far
      as I can see.
      
      These changes will be backported into 4.08.1.
      1da7b45d
  36. 11 Jul, 2000 1 commit