1. 25 Dec, 2007 1 commit
    • chevalier@alum.wellesley.edu's avatar
      Extend API for compiling to and from Core · 98c68a1c
      chevalier@alum.wellesley.edu authored
      Added API support for compiling Haskell to simplified Core, and for
      compiling Core to machine code. The latter, especially, should be
      considered experimental and has only been given cursory testing. Also
      fixed warnings in DriverPipeline. Merry Christmas.
      98c68a1c
  2. 07 Dec, 2007 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Properly keep track of whether normalising given or wanted dicts · b6d08641
      chak@cse.unsw.edu.au. authored
      - The information of whether given or wanted class dictionaries where
        normalised by rewriting wasn't always correctly propagated in TcTyFuns,
        which lead to malformed dictionary bindings.
      - Also fixes a bug in TcPat.tcConPat where GADT equalities where emitted in
        the wrong position in case bindings (which led to CoreLint failures).
      b6d08641
  3. 10 Oct, 2007 1 commit
    • Dan Licata's avatar
      View patterns, record wildcards, and record puns · 6a05ec5e
      Dan Licata authored
      This patch implements three new features:
      * view patterns (syntax: expression -> pat in a pattern)
      * working versions of record wildcards and record puns
      See the manual for detailed descriptions.
      
      Other minor observable changes:
      * There is a check prohibiting local fixity declarations
        when the variable being fixed is not defined in the same let
      * The warn-unused-binds option now reports warnings for do and mdo stmts
      
      Implementation notes: 
      
      * The pattern renamer is now in its own module, RnPat, and the
      implementation is now in a CPS style so that the correct context is
      delivered to pattern expressions.
      
      * These features required a fairly major upheaval to the renamer.
      Whereas the old version used to collect up all the bindings from a let
      (or top-level, or recursive do statement, ...) and put them into scope
      before renaming anything, the new version does the collection as it
      renames.  This allows us to do the right thing with record wildcard
      patterns (which need to be expanded to see what names should be
      collected), and it allows us to implement the desired semantics for view
      patterns in lets.  This change had a bunch of domino effects brought on
      by fiddling with the top-level renaming.
      
      * Prior to this patch, there was a tricky bug in mkRecordSelId in HEAD,
      which did not maintain the invariant necessary for loadDecl.  See note
      [Tricky iface loop] for details.
      6a05ec5e
  4. 03 Oct, 2007 1 commit
  5. 04 Sep, 2007 1 commit
  6. 03 Sep, 2007 1 commit
  7. 01 Sep, 2007 1 commit
  8. 28 Aug, 2007 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Type checking for type synonym families · 5822cb8d
      chak@cse.unsw.edu.au. authored
      This patch introduces type checking for type families of which associated
      type synonyms are a special case. E.g.
      
              type family Sum n m
      
              type instance Sum Zero n = n
              type instance Sum (Succ n) m = Succ (Sum n m)
      
      where
      
              data Zero       -- empty type
              data Succ n     -- empty type
      
      In addition we support equational constraints of the form:
      
              ty1 ~ ty2
      
      (where ty1 and ty2 are arbitrary tau types) in any context where
      type class constraints are already allowed, e.g.
      
              data Equals a b where
                      Equals :: a ~ b => Equals a b
      
      The above two syntactical extensions are disabled by default. Enable
      with the -XTypeFamilies flag.
      
      For further documentation about the patch, see:
      
              * the master plan
                http://hackage.haskell.org/trac/ghc/wiki/TypeFunctions
      
              * the user-level documentation
                http://haskell.org/haskellwiki/GHC/Indexed_types
      
      The patch is mostly backwards compatible, except for:
      
              * Some error messages have been changed slightly.
      
              * Type checking of GADTs now requires a bit more type declarations:
                not only should the type of a GADT case scrutinee be given, but also
                that of any identifiers used in the branches and the return type.
      
      Please report any unexpected behavior and incomprehensible error message 
      for existing code.
      
      Contributors (code and/or ideas):
              Tom Schrijvers
              Manuel Chakravarty
              Simon Peyton-Jones
              Martin Sulzmann 
      with special thanks to Roman Leshchinskiy
      5822cb8d
  9. 09 Aug, 2007 1 commit
  10. 07 Jun, 2007 1 commit
    • David Himmelstrup's avatar
      Fix a bug in MatchCon, and clarify what dataConInstOrigArgTys does · 00b6d256
      David Himmelstrup authored
      There was an outright bug in MatchCon.matchOneCon, in the construction
      of arg_tys.  Easily fixed.  It never showed up becuase the arg_tys are
      only used in WildPats, and they in turn seldom have their types looked
      (except by hsPatType).  So I can't make a test case for htis.
      
      While I was investigating, I added a bit of clarifation and
      invariant-checking to dataConInstOrigArgTys and dataConInstArgTys
      00b6d256
  11. 09 May, 2007 1 commit
  12. 02 May, 2007 2 commits
  13. 22 Apr, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Fixes to datacon wrappers for indexed data types · 70918cf4
      simonpj@microsoft.com authored
      nominolo@gmail.com pointed out (Trac #1204) that indexed data types
      aren't quite right. I investigated and found that the wrapper
      functions for indexed data types, generated in MkId, are really very
      confusing.  In particular, we'd like these combinations to work
      	newtype + indexed data type
      	GADT + indexted data type
      The wrapper situation gets a bit complicated!  
      
      I did a bit of refactoring, and improved matters, I think.  I am not
      certain that I have gotten it right yet, but I think it's better.
      I'm committing it now becuase it's been on my non-backed-up laptop for
      a month and I want to get it into the repo. I don't think I've broken
      anything, but I don't regard it as 'done'.
      70918cf4
  14. 19 Apr, 2007 1 commit
  15. 20 Feb, 2007 1 commit
    • bjpop@csse.unimelb.edu.au's avatar
      Constructor names in info tables · 7d6dffe5
      bjpop@csse.unimelb.edu.au authored
      This patch adds data constructor names into their info tables. 
      This is useful in the ghci debugger. It replaces the old scheme which
      was based on tracking data con names in the linker. 
      7d6dffe5
  16. 11 Jan, 2007 1 commit
  17. 02 Jan, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Big tidy-up of deriving code · 84923cc7
      simonpj@microsoft.com authored
      This tidy-up, triggered by Trac #1068, re-factors the way that 'deriving' 
      happens.  It took me way longer than I had intended.  The main changes,
      by far are to TcDeriv; everyting else is a minor consequence.
      
      While I was at it, I changed the syntax for standalone deriving, so that
      it goes
      	derive instance Show (T a)
      
      (instead of "derive Show for T").  However, there's still an implicit
      context, generated by the deriving code, and I wonder if it shouldn't really
      be
      	derive instance (..) => Show (T a)
      but I have left it simple for now.
      
      I also added a function Type.substTyVars, and used it here and there, which
      led to some one-line changes otherwise unrelated (sorry).
      
      Loose ends:
        * 'deriving Typeable' for indexed data types is still not right
        * standalone deriving should be documented
      84923cc7
  18. 01 Nov, 2006 1 commit
  19. 11 Oct, 2006 1 commit
    • Simon Marlow's avatar
      Module header tidyup, phase 1 · 49c98d14
      Simon Marlow authored
      This patch is a start on removing import lists and generally tidying
      up the top of each module.  In addition to removing import lists:
      
         - Change DATA.IOREF -> Data.IORef etc.
         - Change List -> Data.List etc.
         - Remove $Id$
         - Update copyrights
         - Re-order imports to put non-GHC imports last
         - Remove some unused and duplicate imports
      49c98d14
  20. 04 Oct, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Tidy tyvar OccNames in TcTyClDecl · 4b922606
      simonpj@microsoft.com authored
      We want the universal and existential tyvars of a data constructor to
      have distinct OccNames.  It's confusing if they don't (in error messages,
      for example), and with the current way of generating IfaceSyn, it actally
      generates bogus interface files.  (Which bit Roman.)
      
      When IfaceSyn is full of Names, this won't matter so much, but it still
      seems cleaner.
      
      This patch adds a 'tidy' step to the generation of DataCon type 
      variables in TcTyClDecls.tcResultType 
      4b922606
  21. 23 Sep, 2006 1 commit
  22. 20 Sep, 2006 10 commits
    • chak@cse.unsw.edu.au.'s avatar
      Indexed newtypes · 27897431
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 19:24:27 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Indexed newtypes
        Thu Aug 31 22:09:21 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Indexed newtypes
          - This patch makes indexed newtypes work
          - Only lightly tested
          - We need to distinguish between open and closed newtypes in a number of 
            places, because looking through newtypes doesn't work easily for open ones.
      27897431
    • chak@cse.unsw.edu.au.'s avatar
      Introduce coercions for data instance decls · 909d2dd8
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 19:07:30 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Introduce coercions for data instance decls
        Tue Aug 22 20:33:46 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Introduce coercions for data instance decls
          - data instance declarations implicitly generate a coercion moving between the
            representation type and family instance type.
          - The coercion is *implicitly* generated when type checking both source and 
            ifaces.  Ie, we don't safe it in ifaces - this is really exactly as newtype 
            coercions are handled.
          - The previous addition of the instance types to DataCons has been moved to 
            the representation TyCon.  This is more efficient as it is shared between all
            constructors of one representation tycon and it also gathers everything about
            data instances (family tycon, instance types, and coercion) in one place: the
            algTcParent field of TyCon.
          - The coercion is already used in the datacon wrappers, but not yet during type
            checking pattern matching of indexed data types.
          - The code has only been lightly tested, but doesn't seem to break features not
            related to indexed types.  For indexed data types only the pattern matching
            tc code (in TcPat.tcConPat) and some well-formedness checks are still 
            missing.  And there will surely be some bugs to fix.  (newtypes still require
            some more work.)
          
          	   ** WARNING: Interface file format changed! **
          	   **          Recompile from scratch!        **
      909d2dd8
    • chak@cse.unsw.edu.au.'s avatar
      Extend TyCons and DataCons to represent data instance decls · 80c89b80
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 19:05:18 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Extend TyCons and DataCons to represent data instance decls
        Fri Aug 18 19:11:37 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Extend TyCons and DataCons to represent data instance decls
          - This is a faily involved patch, but it is not entirely complete:
            + The data con wrapper code for instance data cons needs to apply the
              coercions (which we still have to generate).
            + There are still bugs, but it doesn't seem to affect the compilation of
              code that doesn't use type families.
          
          ** WARNING: Yet another change of the iface format.  **
          **          Recompile everything.                    **
      80c89b80
    • chak@cse.unsw.edu.au.'s avatar
      Removed spurious + due to manual patching · 4d9b47b2
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 17:25:23 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Removed spurious + due to manual patching
        Mon Aug  7 11:07:37 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Removed spurious + due to manual patching
      4d9b47b2
    • chak@cse.unsw.edu.au.'s avatar
      Comments about datacon worker and wrappers · bd2fae6c
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 17:21:20 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Comments about datacon worker and wrappers
        Sun Aug  6 20:57:48 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Comments about datacon worker and wrappers
          Fri Aug  4 04:23:28 EDT 2006  simonpj@microsoft.com
      bd2fae6c
    • chak@cse.unsw.edu.au.'s avatar
      Chagne newtype wrapper into worker · 19e64b50
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 17:17:57 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Chagne newtype wrapper into worker
        Sun Aug  6 20:55:30 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Chagne newtype wrapper into worker
          Wed Aug  2 11:54:28 EDT 2006  kevind@bu.edu
      19e64b50
    • chak@cse.unsw.edu.au.'s avatar
      Minor tidying up · 247fd641
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 17:08:30 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Minor tidying up
        Sun Aug  6 20:30:11 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Minor tidying up
          Tue Aug  1 08:51:40 EDT 2006  simonpj@microsoft.com
      247fd641
    • chak@cse.unsw.edu.au.'s avatar
      fixing record selectors · ef47b5c2
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 16:50:18 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * fixing record selectors
        Sun Aug  6 19:56:29 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * fixing record selectors
          Fri Jul 28 10:24:28 EDT 2006  kevind@bu.edu
          - Bad conflict in tcIfaceDataAlt, at a place where the monster patch had a 
            conflict, too.  I have no idea what the right code is.  -=chak
        NB (at time of 2nd merge): previous conflict resolution was fine
      ef47b5c2
    • chak@cse.unsw.edu.au.'s avatar
      fixed bug in product unboxing · 5ed1437f
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 14:48:53 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * fixed bug in product unboxing
        Sat Aug  5 21:46:18 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * fixed bug in product unboxing
          Mon Jul 17 09:10:34 EDT 2006  kevind@bu.edu
      5ed1437f
    • chak@cse.unsw.edu.au.'s avatar
      towards unboxing through newtypes · a4c34367
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 14:44:50 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * towards unboxing through newtypes
        Sat Aug  5 21:42:05 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * towards unboxing through newtypes
          Fri Jul 14 12:02:32 EDT 2006  kevind@bu.edu
      a4c34367
  23. 18 Sep, 2006 3 commits
    • chak@cse.unsw.edu.au.'s avatar
      GADT pattern matching fix · f86fa5fd
      chak@cse.unsw.edu.au. authored
      Sun Aug  6 17:01:59 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * GADT pattern matching fix
        Wed Jul 19 10:53:09 EDT 2006  kevind@bu.edu
      f86fa5fd
    • chak@cse.unsw.edu.au.'s avatar
      Simplify mkDataCon slightly · 8ddec564
      chak@cse.unsw.edu.au. authored
      Sat Aug  5 21:42:48 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Simplify mkDataCon slightly
        Fri Jul 14 12:48:50 EDT 2006  simonpj@microsoft.com
      8ddec564
    • chak@cse.unsw.edu.au.'s avatar
      Massive patch for the first months work adding System FC to GHC #1 · d5bba9ee
      chak@cse.unsw.edu.au. authored
      Fri Aug  4 15:11:01 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Massive patch for the first months work adding System FC to GHC #1
        Broken up massive patch -=chak
        Original log message:  
        This is (sadly) all done in one patch to avoid Darcs bugs.
        It's not complete work... more FC stuff to come.  A compiler
        using just this patch will fail dismally.
      d5bba9ee
  24. 17 May, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Newtype data constructors get a compulsory unfolding · 307ea550
      simonpj@microsoft.com authored
      With this change, newtype data constructors get a "compulsory" unfolding,
      which means that they *must* be inlined, and no top-level definition of
      the constructor is provided at all.  Since these constructors are no-ops,
      I'm not sure why this wasn't the case all along.
      307ea550
  25. 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
  26. 14 Oct, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-10-14 11:22:41 by simonpj] · 36436bc6
      simonpj authored
      Add record syntax for GADTs
      	~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Atrijus Tang wanted to add record syntax for GADTs and existential
      types, so he and I worked on it a bit at ICFP.  This commit is the
      result.  Now you can say
      
       data T a where
        T1 { x :: a }           	 :: T [a]
        T2 { x :: a, y :: Int } 	 :: T [a]
        forall b. Show b =>
       	T3 { naughty :: b, ok :: Int } :: T Int
        T4 :: Eq a => a -> b -> T (a,b)
      
      Here the constructors are declared using record syntax.
      
      Still to come after this commit:
        - User manual documentation
        - More regression tests
        - Some missing cases in the parser (e.g. T3 won't parse)
      Autrijus is going to do these.
      
      
      Here's a quick summary of the rules.  (Atrijus is going to write
      proper documentation shortly.)
      
      Defnition: a 'vanilla' constructor has a type of the form
      	forall a1..an. t1 -> ... -> tm -> T a1 ... an
      No existentials, no context, nothing.  A constructor declared with
      Haskell-98 syntax is vanilla by construction.  A constructor declared
      with GADT-style syntax is vanilla iff its type looks like the above.
      (In the latter case, the order of the type variables does not matter.)
      
      * You can mix record syntax and non-record syntax in a single decl
      
      * All constructors that share a common field 'x' must have the
        same result type (T [a] in the example).
      
      * You can use field names without restriction in record construction
        and record pattern matching.
      
      * Record *update* only works for data types that only have 'vanilla'
        constructors.
      
      * Consider the field 'naughty', which uses a type variable that does
        not appear in the result type ('b' in the example).  You can use the
        field 'naughty' in pattern matching and construction, but NO
        SELECTOR function is generated for 'naughty'.  [An attempt to use
        'naughty' as a selector function will elicit a helpful error
        message.]
      
      * Data types declared in GADT syntax cannot have a context. So this
      is illegal:
      	data (Monad m) => T a where
      		  ....
      
      * Constructors in GADT syntax can have a context (t.g. T3, T4 above)
        and that context is stored in the constructor and made available
        when the constructor is pattern-matched on.  WARNING: not competely
        implemented yet, but that's the plan.
      
      
      
      Implementation notes
      ~~~~~~~~~~~~~~~~~~~~
      - Data constructors (even vanilla ones) no longer share the type
        variables of their parent type constructor.
      
      - HsDecls.ConDecl has changed quite a bit
      
      - TyCons don't record the field labels and type any more (doesn't
        make sense for existential fields)
      
      - GlobalIdDetails records which selectors are 'naughty', and hence
        don't have real code.
      36436bc6
  27. 06 Oct, 2005 1 commit
  28. 16 May, 2005 1 commit