1. 23 Jun, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-06-23 10:35:15 by simonpj] · d28ba8c8
      simonpj authored
      -------------------
      	Dealing with 'main'
      	-------------------
      
      1.  In GHC 6.0, a module with no "module Main ... where" header
          elicited an error "main is not in scope" if 'main' is not defined.  We
          don't want this behaviour in GHCi.  This happened because the parser
          expanded the (absent) header to "module Main( main ) where", and the
          'main' in the export list isn't.
      
      Solution: elaborate HsModule to record whether the 'module ..." header was
      given explicitly by the user or not.
      
      
      2.  Add a -main-is flag, and document it, so that you can have a 'main' function
      that is not Main.main.  Summary of changes
      
      * The -main-is flag nominates what the main function is to be (see the documentation).
      	No -main-is flag 	says that the main function is Main.main
      	-main-is Foo.baz	says that the main function is Foo.baz
      	-main-is Foo		says that the main function is Foo.main
      	-main-is baz		says that the main function is Main.baz
      
        Let's say  you say -main-is Foo.baz
      
      * TcRnDriver injects the extra definition
      	$Mian.main :: IO t
      	$Main.main = baz
        in the module Foo.   Note the naming, which is a bit different than before;
        previously the extra defn was for Main.$main.  The RTS invokes zdMain_main_closure.
      
      * CodeGen injects an extra initialisation block into module Foo, thus
      	stginit_zdMain {
      		stginit_Foo
      	}
        That ensures that the RTS can initialise stginit_zdMain.
      d28ba8c8
  2. 19 May, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-05-19 15:10:40 by simonpj] · 20555469
      simonpj authored
      --------------------------
      	Minor Template Haskell bug
      	--------------------------
      
      This bug meant that spliced-in class declarations yielded a 'op not in scope',
      where op was the class operation.  Thanks to Andre Pang for spotting this.
      
      Some consequential tidying up in parsing too.
      20555469
  3. 06 May, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-05-06 10:25:32 by simonpj] · e4abae1d
      simonpj authored
      -------------------------------------
      		Main module exports
      	-------------------------------------
      
      Make it so that
      
         	    module Main where ....
      
      exports everything defined in Main, as the report says it should.
      e4abae1d
  4. 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
  5. 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
  6. 10 Dec, 2002 1 commit
  7. 25 Oct, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-10-25 15:23:03 by simonpj] · 4ef18ea2
      simonpj authored
      ------------------------
      	More dependency fiddling
      	------------------------
      
      	WARNING: Interface file format has changed (again)
      		 You need to 'make clean' in all library code
      
      * Orphan modules are now kept separately
        Home-package dependencies now contain only home-package dependencies!
        See HscTypes.Dependencies
      
      * Linker now uses the dependencies to do dynamic linking
      
      Result: Template Haskell should work even without --make (not yet tested)
      4ef18ea2
  8. 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
  9. 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
  10. 11 Oct, 2002 2 commits
    • 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
    • simonpj's avatar
      [project @ 2002-10-11 08:48:13 by simonpj] · c1a88920
      simonpj authored
      wibbles
      c1a88920
  11. 10 Oct, 2002 1 commit
  12. 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
  13. 27 Sep, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-09-27 08:20:43 by simonpj] · dbc254c3
      simonpj authored
      --------------------------------
              Implement recursive do-notation
      	--------------------------------
      
      This commit adds recursive do-notation, which Hugs has had for some time.
      
      	mdo { x <- foo y ;
      	      y <- baz x ;
      	      return (y,x) }
      
      turns into
      
      	do { (x,y) <- mfix (\~(x,y) -> do { x <- foo y;
      					    y <- baz x }) ;
      	     return (y,x) }
      
      This is all based on work by Levent Erkok and John Lanuchbury.
      
      The really tricky bit is in the renamer (RnExpr.rnMDoStmts) where
      we break things up into minimal segments.  The rest is easy, including
      the type checker.
      
      Levent laid the groundwork, and Simon finished it off. Needless to say,
      I couldn't resist tidying up other stuff, so there's no guaranteed I
      have not broken something.
      dbc254c3
  14. 25 Sep, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-09-25 12:47:42 by simonmar] · 46732ee6
      simonmar authored
      The variable in a foreign declaration should be 'var' not 'varid',
      which means that the following should be legal:
      
      	foreign export "plusInt" (+) :: Int -> Int -> Int
      
      (this example is even in the FFI spec!)
      46732ee6
  15. 19 Sep, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-09-19 12:31:08 by simonmar] · 9d141631
      simonmar authored
      Fix records with infix constructors (parser/should_compile/read010).
      Also tidy up the parser a bit:
      
       - clean up the tycon productions
      
       - check the current s/r conflicts (29) against reality,
         and update the comment.
      9d141631
  16. 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
  17. 06 Sep, 2002 1 commit
  18. 07 Jun, 2002 1 commit
    • chak's avatar
      [project @ 2002-06-07 07:16:04 by chak] · 2205f0ce
      chak authored
      Fixed handling of infix operators in types:
      - Pretty printing didn't take nested infix operators into account
      - Explicit parenthesis were ignored in the fixity parser:
        * I added a constructor `HsParTy' to `HsType' (in the spirit of `HsPar' in
          `HsExpr'), which tracks the use of explicit parenthesis
        * Occurences of `HsParTy' in type-ish things that are not quite types (like
          context predicates) are removed in `ParseUtils'; all other occurences of
          `HsParTy' are removed during type checking (just as it works with `HsPar')
      2205f0ce
  19. 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
  20. 27 May, 2002 1 commit
    • 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
  21. 10 May, 2002 1 commit
  22. 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
  23. 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
  24. 28 Mar, 2002 1 commit
  25. 14 Mar, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-03-14 15:47:52 by simonmar] · b9312420
      simonmar authored
      Remove the interface file parser, and move .hi-boot parsing into the
      main parser.  The syntax of .hi-boot files is now greatly improved in
      terms of readability; here's an example:
      
      	module M where
      	data T
      	f :: T -> GHC.Base.Int
      
      note that
      	(a) layout can be used
      	(b) there's no explcit export list; everything declared
      	    is implicitly exported
      	(c) Z-encoding of names is no longer required
      	(d) Any identifier not declared in the current module must
      	    still be quailified with the module which originally
      	    defined it (eg. GHC.Base.Int above).
      
      We'd like to relax (d), but that will come later.
      b9312420
  26. 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
  27. 03 Mar, 2002 1 commit
  28. 15 Feb, 2002 1 commit
    • sof's avatar
      [project @ 2002-02-15 22:13:32 by sof] · d95869c5
      sof authored
      New call attribute on foreign imports, threadsafe.
      
      It indicates that a foreign import can(*) safely be called
      concurrently with the continued evaluation of other Haskell
      threads, i.e., when the foreign call is made by a Haskell
      thread, it won't hinder the progress of other threads.
      
      (*) - if the platform and RTS supports it, it _will be_
      invoked concurrently.
      d95869c5
  29. 13 Feb, 2002 2 commits
    • 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
    • simonpj's avatar
      [project @ 2002-02-13 14:05:50 by simonpj] · af93bb78
      simonpj authored
      Import wibbles
      af93bb78
  30. 12 Feb, 2002 1 commit
    • chak's avatar
      [project @ 2002-02-12 03:52:08 by chak] · 2f874c4c
      chak authored
      This fixes a problem with the recent clean up in the parsing of type
      declarations.  The cleaned up version was correct by H98 (I think), but
      unfortunately won't compile the Prelude anymore.
      
      I made the definition a little bit more liberal as follows:
      - In `tycl_hdr' allow `gtycon' instead of just `tycon' for the defined type
        constructor.  This allows beyond H98 special syntax like "[]" etc as well as
        tycon ops in parenthesis.  Moreover, it allows qualified names, but the
        renamer flags the latter as errors.
      - Allow `gtycon' instead of only `qtycon' for the class name in definitions of
        the form `Eq a => T a' to avoid a whole list of s/r conflicts.  (I have *not*
        checked that the renamer flags misuse, but I would expect that it does.)
      
      ToDo: I think, the renamer should raise an error for all these additional
            forms *unless* -fglasgow-exts is given.
      
      In PrelBase, I needed to replace the infix notation by prefix notation in the
      definition of `:+:' and `:*:'.
      2f874c4c
  31. 11 Feb, 2002 3 commits
    • simonpj's avatar
      [project @ 2002-02-11 15:16:25 by simonpj] · 408439c0
      simonpj authored
      ----------------------------------
      	Implement kinded type declarations
      	----------------------------------
      
      This commit allows the programmer to supply kinds in
      	* data decls
      	* type decls
      	* class decls
      	* 'forall's in types
      
      e.g. 	data T (x :: *->*) = MkT
      
              type Composer c = forall (x :: * -> *) (y :: * -> *) (z :: * -> *).
      		          (c y z) -> (c x y) -> (c x z);
      
      This is occasionally useful.
      
      It turned out to be convenient to add the form
      
      	(type :: kind)
      
      to the syntax of types too, so you can put kind signatures in types as well.
      408439c0
    • simonpj's avatar
      [project @ 2002-02-11 09:27:21 by simonpj] · 2dd1686b
      simonpj authored
      ------------------------------
      		Towards kinded data type decls
      		------------------------------
      
      Move towards being able to have 'kinded' data type decls.
      The burden of this commit, though, is to tidy up the parsing
      of data type decls.  Previously we had
      
      	data ctype '=' constrs
      
      where the 'ctype' is a completetely general polymorphic type.
      	forall a. (Eq a) => T a
      
      Then a separate function checked that it was of a suitably restricted
      form.  The reason for this is the usual thing --- it's hard to tell
      when looking at
      
      	data Eq a => T a = ...
      
      whether you are reading the data type or the context when you have
      only got as far as 'Eq a'.
      
      However, the 'ctype' trick doesn't work if we want to allow
      
      	data T (a :: * -> *) = ...
      
      So we have to parse the data type decl in a more serious way.
      That's what this commit does, and it makes the grammar look much nicer.
      The main new producion is tycl_hdr.
      2dd1686b
    • 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
  32. 04 Feb, 2002 1 commit
    • chak's avatar
      [project @ 2002-02-04 03:40:31 by chak] · 0299e1a1
      chak authored
      Foreign import/export declarations now conform to FFI Addendum Version 1.0
      
      * The old form of foreign declarations is still supported, but generates
        deprecation warnings.
      
      * There are some rather exotic old-style declarations which have become
        invalid as they are interpreted differently under the new scheme and there
        is no (easy) way to determine which style the programmer had in mind (eg,
        importing a C function with the name `wrapper' where the external name is
        explicitly given will not work in some situations - depends on whether an
        `unsafe' was specified and similar things).
      
      * Some "new" old-style forms have been introduced to make parsing a little bit
        easier (ie, avoid shift/reduce conflicts between new-style and old-style
        grammar rules), but they are few, arcane, and don't really hurt (and I won't
        tell what they are, you need to find that out by yourself ;-)
      
      * The FFI Addendum doesn't specify whether a header file that is requested for
        inclusion by multiple foreign declarations should be included only once or
        multiple times.  GHC at the moment includes an header as often as it appears
        in a foreign declaration.  For properly written headers, it doesn't make a
        difference anyway...
      
      * Library object specifications are currently silently ignored.  The feature
        was mainly requested for external calls in .NET (ie, calls which invoke C
        routines when Haskell is compiled to ILX), but those don't seem to be
        supported yet.
      
      * Foreign label declarations are currently broken, but they were already
        broken before I started messing with the stuff.
      
      The code is moderately tested.  All modules in lib/std/ and hslibs/lang/
      (using old-style declarations) still compile fine and I have run a couple of
      tests on the different forms of new-style declarations.
      0299e1a1
  33. 29 Jan, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-01-29 09:58:14 by simonpj] · f2054812
      simonpj authored
      ------------
      	Rule phasing
      	------------
      
      This commit adds a little more control to when rules are enabled.
      
        {-# RULES
             "foo" [2] forall ...
             "baz" [~2] forall ...
        #-}
      
      Rule "foo" is active in phase 2 and later.  The new thing is that the
      "~2" means that Rule "baz" is active in phase 3 and earlier.
      (Remember tha phases decrease towards zero.)
      
      All the machinery was there to implement this, it just needed the syntax.
      
      
      Why do this?  Peter Gammie (at UNSW) found that rules weren't firing
      because of bindings of the form
      
      	M.f = f
      	f = ....
      
      where the rules where on the M.f binding.  It turned out that an old
      hack (which have for some time elicited the harmless "shortMeOut" debug
      warnings) prevented this trivial construction from being correctly
      simplified.  The hack in turn derived from a trick in the way the
      foldr/build rule was implemented....and that hack is no longer necessary
      now we can switch rules *off* as well as *on*.
      
      
      There are consequential changes in the Prelude foldr/build RULE stuff.
      It's a clean-up.... Instead of strange definitions like
      	map = mapList
      which we had before, we have an ordinary recursive defn of map, together
      with rules to convert first to foldr/build form, and then (if nothing
      happens) back again.
      
      There's a fairly long comment about the general plan of attack in
      PrelBase, near the defn of map.
      f2054812
  34. 21 Dec, 2001 1 commit
  35. 20 Dec, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-12-20 11:19:05 by simonpj] · 91c750cb
      simonpj authored
      ---------------------------------------------
      	More type system extensions (for John Hughes)
      	---------------------------------------------
      
      1.  Added a brand-new extension that lets you derive ARBITRARY CLASSES
      for newtypes.  Thus
      
      	newtype Age = Age Int deriving( Eq, Ord, Shape, Ix )
      
      The idea is that the dictionary for the user-defined class Shape Age
      is *identical* to that for Shape Int, so there is really no deriving
      work to do.   This saves you writing the very tiresome instance decl:
      
      	instance Shape Age where
      	   shape_op1 (Age x) = shape_op1 x
      	   shape_op2 (Age x1) (Age x2) = shape_op2 x1 x2
      	   ...etc...
      
      It's more efficient, too, becuase the Shape Age dictionary really
      will be identical to the Shape Int dictionary.
      
      There's an exception for Read and Show, because the derived instance
      *isn't* the same.
      
      There is a complication where higher order stuff is involved.  Here is
      the example John gave:
      
         class StateMonad s m | m -> s where ...
      
         newtype Parser tok m a = Parser (State [tok] (Failure m) a)
      			  deriving( Monad, StateMonad )
      
      Then we want the derived instance decls to be
      
         instance Monad (State [tok] (Failure m)) => Monad (Parser tok m)
         instance StateMonad [tok] (State [tok] (Failure m))
      	 => StateMonad [tok] (Parser tok m)
      
      John is writing up manual entry for all of this, but this commit
      implements it.   I think.
      
      
      2.  Added -fallow-incoherent-instances, and documented it.  The idea
      is that sometimes GHC is over-protective about not committing to a
      particular instance, and the programmer may want to say "commit anyway".
      Here's the example:
      
          class Sat a where
            dict :: a
      
          data EqD a = EqD {eq :: a->a->Bool}
      
          instance Sat (EqD a) => Eq a where
            (==) = eq dict
      
          instance Sat (EqD Integer) where
            dict = EqD{eq=(==)}
      
          instance Eq a => Sat (EqD a) where
            dict = EqD{eq=(==)}
      
          class Collection c cxt | c -> cxt where
            empty :: Sat (cxt a) => c a
            single :: Sat (cxt a) => a -> c a
            union :: Sat (cxt a) => c a -> c a -> c a
            member :: Sat (cxt a) => a -> c a -> Bool
      
          instance Collection [] EqD where
            empty = []
            single x = [x]
            union = (++)
            member = elem
      
      It's an updated attempt to model "Restricted Data Types", if you
      remember my Haskell workshop paper. In the end, though, GHC rejects
      the program (even with fallow-overlapping-instances and
      fallow-undecideable-instances), because there's more than one way to
      construct the Eq instance needed by elem.
      
      Yet all the ways are equivalent! So GHC is being a bit over-protective
      of me, really: I know what I'm doing and I would LIKE it to pick an
      arbitrary one. Maybe a flag fallow-incoherent-instances would be a
      useful thing to add?
      91c750cb