1. 23 Sep, 2006 1 commit
  2. 20 Sep, 2006 9 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.
    • chak@cse.unsw.edu.au.'s avatar
      Check category of type instances and some newtype family fixes · d5c4754d
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 19:23:39 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Check category of type instances and some newtype family fixes
        Thu Aug 31 16:54:14 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Check category of type instances and some newtype family fixes
    • chak@cse.unsw.edu.au.'s avatar
      Extended TyCon and friends to represent family declarations · e8a591c1
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 18:50:35 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Extended TyCon and friends to represent family declarations
        Tue Aug 15 16:52:31 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Extended TyCon and friends to represent family declarations
    • chak@cse.unsw.edu.au.'s avatar
      Fix GADT refinement fix-pointing, add ASSERTs and a WARN, make type equality... · 67ee8a93
      chak@cse.unsw.edu.au. authored
      Fix GADT refinement fix-pointing, add ASSERTs and a WARN, make type equality functions work for PredTy Eqtype ...
      Mon Sep 18 17:07:38 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Fix GADT refinement fix-pointing, add ASSERTs and a WARN, make type equality functions work for PredTy Eqtype ...
        Sun Aug  6 20:28:50 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Fix GADT refinement fix-pointing, add ASSERTs and a WARN, make type equality functions work for PredTy Eqtype ...
          Tue Aug  1 06:14:43 EDT 2006  kevind@bu.edu
    • chak@cse.unsw.edu.au.'s avatar
      fix bugs, add boolean flag to identify coercion variables · 0b86bc9b
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 16:41:32 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * fix bugs, add boolean flag to identify coercion variables
        Sun Aug  6 17:04:02 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * fix bugs, add boolean flag to identify coercion variables
          Tue Jul 25 06:20:05 EDT 2006  kevind@bu.edu
    • chak@cse.unsw.edu.au.'s avatar
      fix some coercion kind representation things, extend exprIsConApp_maybe to non-vanilla · 6fcf9006
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 14:51:33 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * fix some coercion kind representation things, extend exprIsConApp_maybe to non-vanilla
        Sat Aug  5 21:48:21 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * fix some coercion kind representation things, extend exprIsConApp_maybe to non-vanilla
          Wed Jul 19 08:06:28 EDT 2006  kevind@bu.edu
    • 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
    • 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.
    • chak@cse.unsw.edu.au.'s avatar
      newtype fixes, coercions for non-recursive newtypes now optional · c94408e5
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 14:24:27 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * newtype fixes, coercions for non-recursive newtypes now optional
        Sat Aug  5 21:19:58 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * newtype fixes, coercions for non-recursive newtypes now optional
          Fri Jul  7 06:11:48 EDT 2006  kevind@bu.edu
  3. 04 Aug, 2006 1 commit
  4. 18 Aug, 2006 1 commit
  5. 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.
  6. 25 Jan, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Simon's big boxy-type commit · ac10f840
      simonpj@microsoft.com authored
      This very large commit adds impredicativity to GHC, plus
      numerous other small things.
      *** WARNING: I have compiled all the libraries, and
      ***	     a stage-2 compiler, and everything seems
      ***	     fine.  But don't grab this patch if you 
      ***	     can't tolerate a hiccup if something is
      ***	     broken.
      The big picture is this:
      a) GHC handles impredicative polymorphism, as described in the
         "Boxy types: type inference for higher-rank types and
         impredicativity" paper
      b) GHC handles GADTs in the new simplified (and very sligtly less
         epxrssive) way described in the
         "Simple unification-based type inference for GADTs" paper
      But there are lots of smaller changes, and since it was pre-Darcs
      they are not individually recorded.
      Some things to watch out for:
      c)   The story on lexically-scoped type variables has changed, as per
           my email.  I append the story below for completeness, but I 
           am still not happy with it, and it may change again.  In particular,
           the new story does not allow a pattern-bound scoped type variable
           to be wobbly, so (\(x::[a]) -> ...) is usually rejected.  This is
           more restrictive than before, and we might loosen up again.
      d)   A consequence of adding impredicativity is that GHC is a bit less
           gung ho about converting automatically between
        	(ty1 -> forall a. ty2)    and    (forall a. ty1 -> ty2)
           In particular, you may need to eta-expand some functions to make
           typechecking work again.
           Furthermore, functions are now invariant in their argument types,
           rather than being contravariant.  Again, the main consequence is
           that you may occasionally need to eta-expand function arguments when
           using higher-rank polymorphism.
      Please test, and let me know of any hiccups
      Scoped type variables in GHC
      	January 2006
      0) Terminology.
         A *pattern binding* is of the form
      	pat = rhs
         A *function binding* is of the form
      	f pat1 .. patn = rhs
         A binding of the formm
      	var = rhs
         is treated as a (degenerate) *function binding*.
         A *declaration type signature* is a separate type signature for a
         let-bound or where-bound variable:
      	f :: Int -> Int
         A *pattern type signature* is a signature in a pattern: 
      	\(x::a) -> x
      	f (x::a) = x
         A *result type signature* is a signature on the result of a
         function definition:
      	f :: forall a. [a] -> a
      	head (x:xs) :: a = x
         The form
      	x :: a = rhs
         is treated as a (degnerate) function binding with a result
         type signature, not as a pattern binding.
      1) The main invariants:
           A) A lexically-scoped type variable always names a (rigid)
       	type variable (not an arbitrary type).  THIS IS A CHANGE.
              Previously, a scoped type variable named an arbitrary *type*.
           B) A type signature always describes a rigid type (since
      	its free (scoped) type variables name rigid type variables).
      	This is also a change, a consequence of (A).
           C) Distinct lexically-scoped type variables name distinct
      	rigid type variables.  This choice is open; 
      2) Scoping
      2(a) If a declaration type signature has an explicit forall, those type
         variables are brought into scope in the right hand side of the 
         corresponding binding (plus, for function bindings, the patterns on
         the LHS).  
      	f :: forall a. a -> [a]
      	f (x::a) = [x :: a, x]
         Both occurences of 'a' in the second line are bound by 
         the 'forall a' in the first line
         A declaration type signature *without* an explicit top-level forall
         is implicitly quantified over all the type variables that are
         mentioned in the type but not already in scope.  GHC's current
         rule is that this implicit quantification does *not* bring into scope
         any new scoped type variables.
      	f :: a -> a
      	f x = ...('a' is not in scope here)...
         This gives compatibility with Haskell 98
      2(b) A pattern type signature implicitly brings into scope any type
         variables mentioned in the type that are not already into scope.
         These are called *pattern-bound type variables*.
      	g :: a -> a -> [a]
      	g (x::a) (y::a) = [y :: a, x]
         The pattern type signature (x::a) brings 'a' into scope.
         The 'a' in the pattern (y::a) is bound, as is the occurrence on 
         the RHS.  
         A pattern type siganture is the only way you can bring existentials 
         into scope.
      	data T where
      	  MkT :: forall a. a -> (a->Int) -> T
      	f x = case x of
      		MkT (x::a) f -> f (x::a)
      2a) QUESTION
      	class C a where
      	  op :: forall b. b->a->a
      	instance C (T p q) where
      	  op = <rhs>
          Clearly p,q are in scope in <rhs>, but is 'b'?  Not at the moment.
          Nor can you add a type signature for op in the instance decl.
          You'd have to say this:
      	instance C (T p q) where
      	  op = let op' :: forall b. ...
      	           op' = <rhs>
      	       in op'
      3) A pattern-bound type variable is allowed only if the pattern's
         expected type is rigid.  Otherwise we don't know exactly *which*
         skolem the scoped type variable should be bound to, and that means
         we can't do GADT refinement.  This is invariant (A), and it is a 
         big change from the current situation.
      	f (x::a) = x	-- NO; pattern type is wobbly
      	g1 :: b -> b
      	g1 (x::b) = x	-- YES, because the pattern type is rigid
      	g2 :: b -> b
      	g2 (x::c) = x	-- YES, same reason
      	h :: forall b. b -> b
      	h (x::b) = x	-- YES, but the inner b is bound
      	k :: forall b. b -> b
      	k (x::c) = x	-- NO, it can't be both b and c
      3a) You cannot give different names for the same type variable in the same scope
          (Invariant (C)):
      	f1 :: p -> p -> p		-- NO; because 'a' and 'b' would be
      	f1 (x::a) (y::b) = (x::a)	--     bound to the same type variable
      	f2 :: p -> p -> p		-- OK; 'a' is bound to the type variable
      	f2 (x::a) (y::a) = (x::a)	--     over which f2 is quantified
      					-- NB: 'p' is not lexically scoped
      	f3 :: forall p. p -> p -> p	-- NO: 'p' is now scoped, and is bound to
      	f3 (x::a) (y::a) = (x::a)	--     to the same type varialble as 'a'
      	f4 :: forall p. p -> p -> p	-- OK: 'p' is now scoped, and its occurences
      	f4 (x::p) (y::p) = (x::p)	--     in the patterns are bound by the forall
      3b) You can give a different name to the same type variable in different
          disjoint scopes, just as you can (if you want) give diferent names to 
          the same value parameter
      	g :: a -> Bool -> Maybe a
      	g (x::p) True  = Just x  :: Maybe p
      	g (y::q) False = Nothing :: Maybe q
      3c) Scoped type variables respect alpha renaming. For example, 
          function f2 from (3a) above could also be written:
      	f2' :: p -> p -> p
      	f2' (x::b) (y::b) = x::b
         where the scoped type variable is called 'b' instead of 'a'.
      4) Result type signatures obey the same rules as pattern types signatures.
         In particular, they can bind a type variable only if the result type is rigid
      	f x :: a = x	-- NO
      	g :: b -> b
      	g x :: b = x	-- YES; binds b in rhs
      5) A *pattern type signature* in a *pattern binding* cannot bind a 
         scoped type variable
      	(x::a, y) = ...		-- Legal only if 'a' is already in scope
         Reason: in type checking, the "expected type" of the LHS pattern is
         always wobbly, so we can't bind a rigid type variable.  (The exception
         would be for an existential type variable, but existentials are not
         allowed in pattern bindings either.)
         Even this is illegal
      	f :: forall a. a -> a
      	f x = let ((y::b)::a, z) = ... 
         Here it looks as if 'b' might get a rigid binding; but you can't bind
         it to the same skolem as a.
      6) Explicitly-forall'd type variables in the *declaration type signature(s)*
         for a *pattern binding* do not scope AT ALL.
      	x :: forall a. a->a	  -- NO; the forall a does 
      	Just (x::a->a) = Just id  --     not scope at all
      	y :: forall a. a->a
      	Just y = Just (id :: a->a)  -- NO; same reason
         THIS IS A CHANGE, but one I bet that very few people will notice.
         Here's why:
      	strange :: forall b. (b->b,b->b)
      	strange = (id,id)
      	x1 :: forall a. a->a
      	y1 :: forall b. b->b
      	(x1,y1) = strange
          This is legal Haskell 98 (modulo the forall). If both 'a' and 'b'
          both scoped over the RHS, they'd get unified and so cannot stand
          for distinct type variables. One could *imagine* allowing this:
      	x2 :: forall a. a->a
      	y2 :: forall a. a->a
      	(x2,y2) = strange
          using the very same type variable 'a' in both signatures, so that
          a single 'a' scopes over the RHS.  That seems defensible, but odd,
          because though there are two type signatures, they introduce just
          *one* scoped type variable, a.
      7) Possible extension.  We might consider allowing
      	\(x :: [ _ ]) -> <expr>
          where "_" is a wild card, to mean "x has type list of something", without
          naming the something.
  7. 21 Nov, 2005 1 commit
  8. 19 Nov, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-11-19 14:59:53 by simonmar] · e72b2ad4
      simonmar authored
      fix repType after changes to the representation of type synonyms.
      This caused the stage2 compiler to crash, because various info tables
      misrepresented the pointerhood of constructor arguments.
  9. 16 Nov, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-11-16 12:55:58 by simonpj] · cdea9949
      simonpj authored
      Two significant changes to the representation of types
      1. Change the representation of type synonyms
          Up to now, type synonym applications have been held in
          *both* expanded *and* un-expanded form.  Unfortunately, this
          has exponential (!) behaviour when type synonyms are deeply
          nested.  E.g.
      	    type P a b = (a,b)
      	    f :: P a (P b (P c (P d e)))
          This showed up in a program of Joel Reymont, now immortalised
          as typecheck/should_compile/syn-perf.hs
          So now synonyms are held as ordinary TyConApps, and expanded
          only on demand.  
          SynNote has disappeared altogether, so the only remaining TyNote
          is a FTVNote.  I'm not sure if it's even useful.
      2. Eta-reduce newtypes
          See the Note [Newtype eta] in TyCon.lhs
          If we have 
      	    newtype T a b = MkT (S a b)
          then, in Core land, we would like S = T, even though the application
          of T is then not saturated. This commit eta-reduces T's RHS, and
          keeps that inside the TyCon (in nt_etad_rhs).  Result is that 
          coreEqType can be simpler, and has less need of expanding newtypes.
  10. 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'
      * 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
      * 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.
  11. 11 Aug, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-08-11 08:04:33 by simonpj] · 89627230
      simonpj authored
      Do 'tidying' on Kinds before printing them.  This avoids printing
      stuff like 'k_43b' in user error messages.
      To do this, I ended up adding an OccName to Kind.KindVar.  Even
      then the implementation is a bit of hack (see comments with 
      Type.tidyKind).  Still, it's a highly localised hack, whereas the
      "right thing" entails making KindVar into a flavour of Var, which
      seems like an uncomfortably big change.
         I think this change can merge to the stable branch
  12. 16 May, 2005 1 commit
  13. 31 Mar, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-03-31 10:16:33 by simonmar] · 853e20a3
      simonmar authored
      Tweaks to get the GHC sources through Haddock.  Doesn't quite work
      yet, because Haddock complains about the recursive modules.  Haddock
      needs to understand SOURCE imports (it can probably just ignore them
      as a first attempt).
  14. 18 Mar, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-03-18 13:37:27 by simonmar] · d1c1b7d0
      simonmar authored
      Flags cleanup.
      Basically the purpose of this commit is to move more of the compiler's
      global state into DynFlags, which is moving in the direction we need
      to go for the GHC API which can have multiple active sessions
      supported by a single GHC instance.
      $ grep 'global_var' */*hs | wc -l
      $ grep 'global_var' */*hs | wc -l
      Well, it's an improvement.  Most of what's left won't really affect
      our ability to host multiple sessions.
      Lots of static flags have become dynamic flags (yay!).  Notably lots
      of flags that we used to think of as "driver" flags, like -I and -L,
      are now dynamic.  The most notable static flags left behind are the
      "way" flags, eg. -prof.  It would be nice to fix this, but it isn't
      On the way, lots of cleanup has happened.  Everything related to
      static and dynamic flags lives in StaticFlags and DynFlags
      respectively, and they share a common command-line parser library in
      CmdLineParser.  The flags related to modes (--makde, --interactive
      etc.) are now private to the front end: in fact private to Main
      itself, for now.
  15. 31 Jan, 2005 1 commit
  16. 26 Jan, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-01-26 16:10:02 by simonpj] · 8254dcf1
      simonpj authored
      	Fixup to hoistForAllTys
      * hoistForAllTys moves from TcHsType to TcType
      hoistForAllTys was being too vigorous and breaking up type synonyms,
      even when it was entirely unnecessary to do so.
      Not only does this make error messsages less good, but it's actually
      wrong for Haskell 98, because we are meant to report under-applied
      type synonyms, and that check doesn't happen until after hoistForAllTys.
      This led to a very obscure bug, immortalised as tcfail129.
  17. 05 Jan, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-01-05 15:28:39 by simonpj] · 19da321b
      simonpj authored
                GADTs and unification
      1. Adjustment to typechecking of pattern matching the call to
         gadtRefineTys in TcPat.  Now wobbly types are treated as wild
         cards in the unification process.
      2. Add the WildCard possibility to the BindFlag in types/Unify.lhs
      3. Some related refactoring of tcMatchTys etc.
  18. 30 Dec, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-12-30 22:14:59 by simonpj] · 7f05f109
      simonpj authored
      Fix to the pre-Xmas simplifier changes, which should make 
      everything work again.  I'd forgotten to attend to this
      corner.  Still not properly tested I fear.
      Also remove dead code from SimplEnv, and simplify the remainder (hooray).
  19. 24 Dec, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-12-24 16:14:36 by simonpj] · 339d5220
      simonpj authored
                Refactor the simplifier
      Driven by a GADT bug, I have refactored the simpifier, and the way GHC
      treats substitutions.  I hope I have gotten it right.  Be cautious about updating.
      * coreSyn/Subst.lhs has gone
      * coreSyn/CoreSubst replaces it, except that it's quite a bit simpler
      * simplCore/SimplEnv is added, and contains the simplifier-specific substitution
      Previously Subst was trying to be all things to all men, and that was making
      it Too Complicated.
      There may be a little more code now, but it's much easier to understand.
  20. 21 Dec, 2004 2 commits
    • simonpj's avatar
      [project @ 2004-12-21 12:22:22 by simonpj] · 79a8b87c
      simonpj authored
           Improve handling of lexically scoped type variables
      If we have
      	f :: T a -> a
      	f (x :: T b) = ...
      then the lexically scoped variable 'b' should refer to the rigid
      type variable 'a', without any intervening wobbliness.  Previously
      the in-scope type variables were always mutable TyVars, which were
      instantatiated to point to the type they were bound to; but since
      the advent of GADTs the intervening mutable type variable is a bad
        * In the type environment, ATyVar now carries a type
        * The call to refineTyVars in tc_pat on SigPatIn
          finds the types by matching
        * Then tcExtendTyVarEnv3 extends the type envt appropriately
      Rater a lot of huff and puff, but it's quite natural for ATyVar
      to contain a type.
      Various other small nomenclature changes along the way.
    • simonpj's avatar
      [project @ 2004-12-21 09:08:08 by simonpj] · b783b864
      simonpj authored
      Fix bogon in type comparison
  21. 20 Dec, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-12-20 17:16:24 by simonpj] · c45a0ac5
      simonpj authored
      	Deal properly with dual-renaming
      When comparing types and terms, and during matching, we are faced
      	\x.e1	~   \y.e2
      There are many pitfalls here, and GHC has never done the job properly.
      Now, at last it does, using a new abstraction VarEnv.RnEnv2.  See
      comments there for how it works.
      There are lots of consequential changes to use the new stuff, especially
      	types/Type (type comparison), 
      	types/Unify (matching on types)
      	coreSyn/CoreUtils (equality on expressions), 
      	specialise/Rules (matching).
      I'm not 100% certain of that I've covered all the bases, so let me
      know if something unexpected happens after you update.  Maybe wait until
      a nightly build has worked ok first!
  22. 01 Oct, 2004 2 commits
    • simonpj's avatar
      [project @ 2004-10-01 13:42:04 by simonpj] · 837824d2
      simonpj authored
      	Simplify the treatment of newtypes
      	Complete hi-boot file consistency checking
      In the representation of types, newtypes used to have a special constructor
      all to themselves, very like TyConApp, called NewTcApp.    The trouble is
      that means we have to *know* when a newtype is a newtype, and in an hi-boot
      context we may not -- the data type might be declared as
      	data T
      in the hi-boot file, but as
      	newtype T = ...
      in the source file.  In GHCi, which accumulates stuff from multiple compiles,
      this makes a difference.
      So I've nuked NewTcApp.  Newtypes are represented using TyConApps again. This
      turned out to reduce the total amount of code, and simplify the Type data type,
      which is all to the good.
      This commit also fixes a few things in the hi-boot consistency checking
    • simonpj's avatar
      [project @ 2004-10-01 10:08:49 by simonpj] · da95f4a0
      simonpj authored
      	Do simple checking on hi-boot files
      This commit arranges that, when compiling A.hs, we compare
      the types we infer with those in A.hi-boot, if the latter 
      exists.  (Or, more accurately, if anything A.hs imports in
      turn imports A.hi-boot, directly or indirectly.)
      This has been on the to-do list forever.
  23. 30 Sep, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-09-30 10:35:15 by simonpj] · 23f40f0e
      simonpj authored
      	Add Generalised Algebraic Data Types
      This rather big commit adds support for GADTs.  For example,
          data Term a where
       	  Lit :: Int -> Term Int
      	  App :: Term (a->b) -> Term a -> Term b
      	  If  :: Term Bool -> Term a -> Term a
          eval :: Term a -> a
          eval (Lit i) = i
          eval (App a b) = eval a (eval b)
          eval (If p q r) | eval p    = eval q
          		    | otherwise = eval r
      Lots and lots of of related changes throughout the compiler to make
      this fit nicely.
      One important change, only loosely related to GADTs, is that skolem
      constants in the typechecker are genuinely immutable and constant, so
      we often get better error messages from the type checker.  See
      There's a new module types/Unify.lhs, which has purely-functional
      unification and matching for Type. This is used both in the typechecker
      (for type refinement of GADTs) and in Core Lint (also for type refinement).
  24. 13 Aug, 2004 1 commit
  25. 17 Mar, 2004 1 commit
    • simonpj's avatar
      [project @ 2004-03-17 13:59:06 by simonpj] · af5a2151
      simonpj authored
      	More newtype clearing up
      * Change the representation of TyCons so that it accurately reflects
      	* data     (0 or more constrs)
      	* newtype  (1 constr)
      	* abstract (unknown)
        Replaces DataConDetails and AlgTyConFlavour with AlgTyConRhs
      * Add IfaceSyn.IfaceConDecls, a kind of stripped-down analogue
        of AlgTyConRhs
      * Move NewOrData from BasicTypes to HsDecl (it's now an HsSyn thing)
      * Arrange that Type.newTypeRep and splitRecNewType_maybe unwrap just
        one layer of new-type-ness, leaving the caller to recurse.
        This still leaves typeRep and repType in Type.lhs; these functions
        are still vaguely disturbing and probably should get some attention.
      Lots of knock-on changes.  Fixes bug in ds054.
  26. 12 Jan, 2004 1 commit
  27. 30 Dec, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-12-30 16:29:17 by simonpj] · f714e6b6
      simonpj authored
              Re-do kind inference (again)
         [WARNING: interface file binary representation has
         (as usual) changed slightly; recompile your libraries!]
      Inspired by the lambda-cube, for some time GHC has used
      	type Kind = Type
      That is, kinds were represented by the same data type as types.
      But GHC also supports unboxed types and unboxed tuples, and these
      complicate the kind system by requiring a sub-kind relationship.
      Notably, an unboxed tuple is acceptable as the *result* of a
      function but not as an *argument*.  So we have the following setup:
      		/ \
      	       /   \
      	      ??   (#)
      	     /  \
                  *   #
      where	*    [LiftedTypeKind]   means a lifted type
      	#    [UnliftedTypeKind] means an unlifted type
      	(#)  [UbxTupleKind]     means unboxed tuple
      	??   [ArgTypeKind]      is the lub of *,#
      	?    [OpenTypeKind]	means any type at all
      In particular:
        error :: forall a:?. String -> a
        (->)  :: ?? -> ? -> *
        (\(x::t) -> ...)	Here t::?? (i.e. not unboxed tuple)
      All this has beome rather difficult to accommodate with Kind=Type, so this
      commit splits the two.
        * Kind is a distinct type, defined in types/Kind.lhs
        * IfaceType.IfaceKind disappears: we just re-use Kind.Kind
        * TcUnify.unifyKind is a distinct unifier for kinds
        * TyCon no longer needs KindCon and SuperKindCon variants
        * TcUnify.zapExpectedType takes an expected Kind now, so that
          in TcPat.tcMonoPatBndr we can express that the bound variable
          must have an argTypeKind (??).
      The big change is really that kind inference is much more systematic and
      well behaved.  In particular, a kind variable can unify only with a
      "simple kind", which is built from * and (->).  This deals neatly
      with awkward questions about how we can combine sub-kinding with type
      Lots of small consequential changes, especially to the kind-checking
      plumbing in TcTyClsDecls.  (We played a bit fast and loose before, and
      now we have to be more honest, in particular about how kind inference
      works for type synonyms.  They can have kinds like (* -> #), so
      This cures two long-standing SourceForge bugs
      * 753777 (tcfail115.hs), which used erroneously to pass,
        but crashed in the code generator
            type T a = Int -> (# Int, Int #)
            f :: T a -> T a
            f t = \x -> case t x of r -> r
      * 753780 (tc167.hs), which used erroneously to fail
            f :: (->) Int# Int#
      Still, the result is not entirely satisfactory.  In particular
      * The error message from tcfail115 is pretty obscure
      * SourceForge bug 807249 (Instance match failure on openTypeKind)
        is not fixed.  Alas.
  28. 03 Nov, 2003 1 commit
  29. 30 Oct, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-10-30 16:01:49 by simonpj] · 57573e7e
      simonpj authored
      This commit does a long-overdue tidy-up
      * Remove PprType (gets rid of one more bunch of hi-boot files)
      * Put pretty-printing for types in TypeRep
      * Make a specialised pretty-printer for Types, rather than
        converting to IfaceTypes and printing those
  30. 10 Oct, 2003 1 commit