1. 20 Nov, 2007 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      TcPat.tcConPat uses equalities instead of GADT refinement · a003ad80
      chak@cse.unsw.edu.au. authored
      * This patch implements the use of equality constraints instead of GADT
        refinements that we have been discussing for a while.
      * It just changes TcPat.tcConPat.  It doesn't have any of the simplification
        and dead code removal that is possible due to this change.
      * At the moment, this patch breaks a fair number of GADT regression tests.
      a003ad80
  2. 21 Nov, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Make rebindable do-notation behave as advertised · 1d1c3c72
      simonpj@microsoft.com authored
      Adopt Trac #1537.  The patch ended up a bit bigger than I expected,
      so I suggest we do not merge this into the 6.8 branch.  But there
      is no funadamental reason why not.
      
      With this patch, rebindable do-notation really does type as if you
      had written the original (>>) and (>>=) operations in desguared form.
      
      I ended up refactoring some of the (rather complicated) error-context
      stuff in TcUnify, by pushing an InstOrigin into tcSubExp and its
      various calls. That means we could get rid of tcFunResTy, and the
      SubCtxt type.  This should improve error messages slightly
      in complicated situations, because we have an Origin to hand
      to instCall (in the (isSigmaTy actual_ty) case of tc_sub1).
      
      Thanks to Pepe for the first draft of the patch.
      1d1c3c72
  3. 19 Nov, 2007 1 commit
  4. 14 Nov, 2007 1 commit
  5. 16 Oct, 2007 1 commit
  6. 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
  7. 29 Sep, 2007 1 commit
  8. 28 Sep, 2007 1 commit
  9. 06 Sep, 2007 1 commit
  10. 04 Sep, 2007 1 commit
  11. 03 Sep, 2007 1 commit
  12. 01 Sep, 2007 1 commit
  13. 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
  14. 21 Jun, 2007 3 commits
    • simonpj@microsoft.com's avatar
    • simonpj@microsoft.com's avatar
      e2b5796d
    • David Himmelstrup's avatar
      Add several new record features · 2eb04ca0
      David Himmelstrup authored
      1. Record disambiguation (-fdisambiguate-record-fields)
      
      In record construction and pattern matching (although not
      in record updates) it is clear which field name is intended
      even if there are several in scope.  This extension uses
      the constructor to disambiguate.  Thus
      	C { x=3 }
      uses the 'x' field from constructor C (assuming there is one)
      even if there are many x's in scope.
      
      
      2. Record punning (-frecord-puns)
      
      In a record construction or pattern match or update you can 
      omit the "=" part, thus
      	C { x, y }
      This is just syntactic sugar for
      	C { x=x, y=y }
      
      
      3.  Dot-dot notation for records (-frecord-dot-dot)
      
      In record construction or pattern match (but not update) 
      you can use ".." to mean "all the remaining fields".  So
      
      	C { x=v, .. }
      
      means to fill in the remaining fields to give
      
      	C { x=v, y=y }
      
      (assuming C has fields x and y).  This might reasonably
      considered very dodgy stuff.  For pattern-matching it brings
      into scope a bunch of things that are not explictly mentioned;
      and in record construction it just picks whatver 'y' is in
      scope for the 'y' field.   Still, Lennart Augustsson really
      wants it, and it's a feature that is extremely easy to explain.
      
      
      Implementation
      ~~~~~~~~~~~~~~
      I thought of using the "parent" field in the GlobalRdrEnv, but
      that's really used for import/export and just isn't right for this.
      For example, for import/export a field is a subordinate of the *type
      constructor* whereas here we need to know what fields belong to a
      particular *data* constructor.
      
      The main thing is that we need to map a data constructor to its
      fields, and we need to do so in the renamer.   For imported modules
      it's easy: just look in the imported TypeEnv.  For the module being
      compiled, we make a new field tcg_field_env in the TcGblEnv.
      The important functions are
      	RnEnv.lookupRecordBndr
      	RnEnv.lookupConstructorFields
      
      There is still a significant infelicity in the way the renamer
      works on patterns, which I'll tackle next.
      
      
      I also did quite a bit of refactoring in the representation of
      record fields (mainly in HsPat).***END OF DESCRIPTION***
      
      Place the long patch description above the ***END OF DESCRIPTION*** marker.
      The first line of this file will be the patch name.
      
      
      This patch contains the following changes:
      
      M ./compiler/deSugar/Check.lhs -3 +5
      M ./compiler/deSugar/Coverage.lhs -6 +7
      M ./compiler/deSugar/DsExpr.lhs -6 +13
      M ./compiler/deSugar/DsMeta.hs -8 +8
      M ./compiler/deSugar/DsUtils.lhs -1 +1
      M ./compiler/deSugar/MatchCon.lhs -2 +2
      M ./compiler/hsSyn/Convert.lhs -3 +3
      M ./compiler/hsSyn/HsDecls.lhs -9 +25
      M ./compiler/hsSyn/HsExpr.lhs -13 +3
      M ./compiler/hsSyn/HsPat.lhs -25 +63
      M ./compiler/hsSyn/HsUtils.lhs -3 +3
      M ./compiler/main/DynFlags.hs +6
      M ./compiler/parser/Parser.y.pp -13 +17
      M ./compiler/parser/RdrHsSyn.lhs -16 +18
      M ./compiler/rename/RnBinds.lhs -2 +2
      M ./compiler/rename/RnEnv.lhs -22 +82
      M ./compiler/rename/RnExpr.lhs -34 +12
      M ./compiler/rename/RnHsSyn.lhs -3 +2
      M ./compiler/rename/RnSource.lhs -50 +78
      M ./compiler/rename/RnTypes.lhs -50 +84
      M ./compiler/typecheck/TcExpr.lhs -18 +18
      M ./compiler/typecheck/TcHsSyn.lhs -20 +21
      M ./compiler/typecheck/TcPat.lhs -8 +6
      M ./compiler/typecheck/TcRnMonad.lhs -6 +15
      M ./compiler/typecheck/TcRnTypes.lhs -2 +11
      M ./compiler/typecheck/TcTyClsDecls.lhs -3 +4
      M ./docs/users_guide/flags.xml +7
      M ./docs/users_guide/glasgow_exts.xml +42
      2eb04ca0
  15. 18 Jun, 2007 1 commit
  16. 20 Jun, 2007 1 commit
  17. 05 Jun, 2007 1 commit
  18. 02 May, 2007 1 commit
  19. 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
  20. 04 Feb, 2007 1 commit
  21. 21 Dec, 2006 1 commit
    • lennart@augustsson.net's avatar
      Add support for overloaded string literals. · 90dc9026
      lennart@augustsson.net authored
      The class is named IsString with the single method fromString.
      Overloaded strings work the same way as overloaded numeric literals.
      In expressions a string literals gets a fromString applied to it.
      In a pattern there will be an equality comparison with the fromString:ed literal.
      
      Use -foverloaded-strings to enable this extension.
       
      90dc9026
  22. 03 Jan, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Fix several bugs related to finding free variables · 8ffdb8ee
      simonpj@microsoft.com authored
      Now that coercion variables mention types, a type-lambda binder can
      have free variables.  This patch adjusts the free-variable finder
      to take account of this, by treating Ids and TyVars more uniformly.
      
      In addition, I fixed a bug in the specialiser that was missing a 
      free type variable in a binder.  And a bug in tyVarsOfInst that
      was missing the type variables in the kinds of the quantified tyvars.
      8ffdb8ee
  23. 11 Dec, 2006 2 commits
  24. 24 Nov, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Fix constraint handling for lazy patterns · 36d207aa
      simonpj@microsoft.com authored
      Lazy patterns are quite tricky!  Consider
      	f ~(C x) = 3
      Can the Num constraint from the 3 be discharged by a Num dictionary
      bound by the pattern?  Definitely not!  
      
      See Note [Hopping the LIE in lazy patterns] in TcPat
      
      The type checker wasn't ensuring this, and that was causing all
      manner of strange things to happen.  It actually manifested as a
      strictness bug reported by Sven Panne.
      
      I've added his test case as tcrun040.
      36d207aa
  25. 22 Nov, 2006 1 commit
  26. 10 Nov, 2006 1 commit
  27. 13 Oct, 2006 1 commit
  28. 11 Oct, 2006 2 commits
  29. 05 Oct, 2006 1 commit
  30. 29 Sep, 2006 1 commit
  31. 23 Sep, 2006 1 commit
  32. 22 Sep, 2006 1 commit
  33. 20 Sep, 2006 4 commits
    • chak@cse.unsw.edu.au.'s avatar
      Adapt TcFix imports · 08093c69
      chak@cse.unsw.edu.au. authored
      Tue Sep 19 14:11:55 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Adapt TcFix imports
      08093c69
    • 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
      Pattern matching of indexed data types · 6791ad22
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 19:11:24 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Pattern matching of indexed data types
        Thu Aug 24 14:17:44 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Pattern matching of indexed data types
          - This patch is the last major puzzle piece to type check and desugar indexed 
            data types (both toplevel and associated with a class).
          - However, it needs more testing - esp wrt to accumlating CoPats - and some 
            static sanity checks for data instance declarations are still missing.
          - There are now two detailed notes in MkIds and TcPat on how the worker/wrapper
            and coercion story for indexed data types works.
      6791ad22
    • chak@cse.unsw.edu.au.'s avatar
      Complete the evidence generation for GADTs · 15cb792d
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 14:43:22 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Complete the evidence generation for GADTs
        Sat Aug  5 21:39:51 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Complete the evidence generation for GADTs
          Thu Jul 13 17:18:07 EDT 2006  simonpj@microsoft.com
            
            This patch completes FC evidence generation for GADTs.
            
            It doesn't work properly yet, because part of the compiler thinks
            	(t1 :=: t2) => t3
            is represented with FunTy/PredTy, while the rest thinks it's represented
            using ForAllTy.  Once that's done things should start to work.
      15cb792d