GHC:f37e239fb5e81fc493e0ea1af98178bf1f7ceaba commitshttps://gitlab.haskell.org/ghc/ghc/-/commits/f37e239fb5e81fc493e0ea1af98178bf1f7ceaba2006-09-23T03:52:01+00:00https://gitlab.haskell.org/ghc/ghc/-/commit/f37e239fb5e81fc493e0ea1af98178bf1f7ceabaTrim imports, and remove some dead code2006-09-23T03:52:01+00:00simonpj@microsoft.comunknownhttps://gitlab.haskell.org/ghc/ghc/-/commit/27897431cf24d4bde04b15947440c7205f2d703cIndexed newtypes2006-09-20T18:40:35+00:00Manuel M T Chakravartychak@cse.unsw.edu.auMon 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.https://gitlab.haskell.org/ghc/ghc/-/commit/d5c4754dcb857be7b9f4dbf6482e6050a9cd0991Check category of type instances and some newtype family fixes2006-09-20T18:40:13+00:00Manuel M T Chakravartychak@cse.unsw.edu.auMon 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 fixeshttps://gitlab.haskell.org/ghc/ghc/-/commit/e8a591c1a3dbdeccec2dd2aacccd7435004b0d51Extended TyCon and friends to represent family declarations2006-09-20T18:34:00+00:00Manuel M T Chakravartychak@cse.unsw.edu.auMon 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 declarationshttps://gitlab.haskell.org/ghc/ghc/-/commit/67ee8a93fc96a38c3f73468cb86d8421a11d2911Fix GADT refinement fix-pointing, add ASSERTs and a WARN, make type equality...2006-09-20T17:58:30+00:00Manuel M T Chakravartychak@cse.unsw.edu.auFix 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
https://gitlab.haskell.org/ghc/ghc/-/commit/0b86bc9b022a5965d2b35f143ff4b919f784e676fix bugs, add boolean flag to identify coercion variables2006-09-20T17:39:27+00:00Manuel M T Chakravartychak@cse.unsw.edu.auMon 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.eduhttps://gitlab.haskell.org/ghc/ghc/-/commit/6fcf90065dc4e75b7dc6bbf238a9891a71ae5a86fix some coercion kind representation things, extend exprIsConApp_maybe to no...2006-09-20T17:38:56+00:00Manuel M T Chakravartychak@cse.unsw.edu.auMon 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.eduhttps://gitlab.haskell.org/ghc/ghc/-/commit/a4c34367ce3e836f52f0ffb1e379ce81b8d65316towards unboxing through newtypes2006-09-20T17:35:26+00:00Manuel M T Chakravartychak@cse.unsw.edu.auMon 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.eduhttps://gitlab.haskell.org/ghc/ghc/-/commit/15cb792d18b1094e98c035dca6ecec5dad516056Complete the evidence generation for GADTs2006-09-20T17:05:28+00:00Manuel M T Chakravartychak@cse.unsw.edu.auMon 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.https://gitlab.haskell.org/ghc/ghc/-/commit/c94408e522e5af3b79a5beadc7e6d15cee553ee7newtype fixes, coercions for non-recursive newtypes now optional2006-09-20T16:53:13+00:00Manuel M T Chakravartychak@cse.unsw.edu.auMon 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.eduhttps://gitlab.haskell.org/ghc/ghc/-/commit/c76c69c5b62f1ca4fa52d75b0dfbd37b7eddbb09Massive patch for the first months work adding System FC to GHC #352006-08-04T22:23:51+00:00Manuel M T Chakravartychak@cse.unsw.edu.au
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.https://gitlab.haskell.org/ghc/ghc/-/commit/3287fb1d88a8322a767e45eaea431dacc05862dcBetter pretty-printing for TvSubst2006-08-18T16:05:51+00:00simonpj@microsoft.comunknownhttps://gitlab.haskell.org/ghc/ghc/-/commit/0065d5ab628975892cea1ec7303f968c3338cbe1Reorganisation of the source tree2006-04-07T02:05:11+00:00Simon Marlowsimonmar@microsoft.comMost 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.https://gitlab.haskell.org/ghc/ghc/-/commit/ac10f8408520a30e8437496d320b8b86afda2e8fSimon's big boxy-type commit2006-01-25T16:28:32+00:00simonpj@microsoft.comunknown
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) = ...
in
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.
https://gitlab.haskell.org/ghc/ghc/-/commit/7fe1172a74da728154d3d86729afdb59855406dd[project @ 2005-11-21 10:51:36 by simonpj]2005-11-21T10:51:36+00:00simonpjunknownWibble to typerep (fixes crash I hope)https://gitlab.haskell.org/ghc/ghc/-/commit/e72b2ad40adbd9afa8c68af8429150b6b5e485a1[project @ 2005-11-19 14:59:53 by simonmar]2005-11-19T14:59:53+00:00simonmarunknownfix 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.https://gitlab.haskell.org/ghc/ghc/-/commit/cdea99491a8dedfc53fc2e8c4c8fbaf209802b27[project @ 2005-11-16 12:55:58 by simonpj]2005-11-16T12:55:59+00:00simonpjunknownTwo 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.https://gitlab.haskell.org/ghc/ghc/-/commit/36436bc62a98f53e126ec02fe946337c4c766c3f[project @ 2005-10-14 11:22:41 by simonpj]2005-10-14T11:22:42+00:00simonpjunknownAdd 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.https://gitlab.haskell.org/ghc/ghc/-/commit/89627230a1b0e25a148621509d19297454f692eb[project @ 2005-08-11 08:04:33 by simonpj]2005-08-11T08:04:34+00:00simonpjunknownDo '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 branchhttps://gitlab.haskell.org/ghc/ghc/-/commit/4898649ce5d8bd677450988f6c3d3a39e146daac[project @ 2005-05-16 12:39:15 by simonpj]2005-05-16T12:39:15+00:00simonpjunknownAdd assertions (only)https://gitlab.haskell.org/ghc/ghc/-/commit/853e20a3eb86137cdb8accf69c6caa9db83a3d34[project @ 2005-03-31 10:16:33 by simonmar]2005-03-31T10:16:46+00:00simonmarunknownTweaks 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).https://gitlab.haskell.org/ghc/ghc/-/commit/d1c1b7d0e7b94ede238845c91f58582bad3b3ef3[project @ 2005-03-18 13:37:27 by simonmar]2005-03-18T13:41:59+00:00simonmarunknownFlags 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.
Before:
$ grep 'global_var' */*hs | wc -l
78
After:
$ grep 'global_var' */*hs | wc -l
27
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
urgent.
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.https://gitlab.haskell.org/ghc/ghc/-/commit/04612d54b51bebf809717d1cf0242efb6294ee59[project @ 2005-01-31 13:22:57 by simonpj]2005-01-31T13:23:17+00:00simonpjunknownRename mkTvSubst to mkOpenTvSubst; add new mkTvSubsthttps://gitlab.haskell.org/ghc/ghc/-/commit/8254dcf1884fde961c477d5784024ec8ab1d84d2[project @ 2005-01-26 16:10:02 by simonpj]2005-01-26T16:10:06+00:00simonpjunknown-----------------------
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.https://gitlab.haskell.org/ghc/ghc/-/commit/19da321b73fb79535f72bf4abac69a3592f10e6d[project @ 2005-01-05 15:28:39 by simonpj]2005-01-05T15:28:54+00:00simonpjunknown------------------------
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.https://gitlab.haskell.org/ghc/ghc/-/commit/7f05f1095e9a2c7b2b378859da00fde7ca907080[project @ 2004-12-30 22:14:59 by simonpj]2004-12-30T22:15:19+00:00simonpjunknownFix 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).https://gitlab.haskell.org/ghc/ghc/-/commit/339d5220bcb7e8ca344ca5ec6e862d2373267be8[project @ 2004-12-24 16:14:36 by simonpj]2004-12-24T16:15:15+00:00simonpjunknown---------------------------
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
stuff
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.https://gitlab.haskell.org/ghc/ghc/-/commit/79a8b87c0bd61d56b4cf45bd584c9174aab48e61[project @ 2004-12-21 12:22:22 by simonpj]2004-12-21T12:23:03+00:00simonpjunknown---------------------------------
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
thing.
Hence
* 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.https://gitlab.haskell.org/ghc/ghc/-/commit/b783b8644d142d12c832e261ba60bc81c19c3a12[project @ 2004-12-21 09:08:08 by simonpj]2004-12-21T09:08:08+00:00simonpjunknownFix bogon in type comparisonhttps://gitlab.haskell.org/ghc/ghc/-/commit/c45a0ac5fdc6a931c3bc1a45fd4967f54c2983ca[project @ 2004-12-20 17:16:24 by simonpj]2004-12-20T17:17:10+00:00simonpjunknown--------------------------------
Deal properly with dual-renaming
--------------------------------
When comparing types and terms, and during matching, we are faced
with
\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
in
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!https://gitlab.haskell.org/ghc/ghc/-/commit/837824d2ff329a0f68c1434ae6812bea3ac7ec5f[project @ 2004-10-01 13:42:04 by simonpj]2004-10-01T13:42:57+00:00simonpjunknown------------------------------------
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
stuff.https://gitlab.haskell.org/ghc/ghc/-/commit/da95f4a039f7bc12b625338353df8399dec41c5e[project @ 2004-10-01 10:08:49 by simonpj]2004-10-01T10:09:36+00:00simonpjunknown-----------------------------------
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.https://gitlab.haskell.org/ghc/ghc/-/commit/23f40f0e9be6d4aa5cf9ea31d73f4013f8e7b4bd[project @ 2004-09-30 10:35:15 by simonpj]2004-09-30T10:40:21+00:00simonpjunknown------------------------------------
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
..etc..
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
TcType.TcTyVarDetails.
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).https://gitlab.haskell.org/ghc/ghc/-/commit/423d477bfecd490de1449c59325c8776f91d7aac[project @ 2004-08-13 13:04:50 by simonmar]2004-08-13T13:11:23+00:00simonmarunknownMerge backend-hacking-branch onto HEAD. Yay!https://gitlab.haskell.org/ghc/ghc/-/commit/af5a215172aa3b964ece212f229bfee9f7c6b6b2[project @ 2004-03-17 13:59:06 by simonpj]2004-03-17T13:59:19+00:00simonpjunknown------------------------
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.https://gitlab.haskell.org/ghc/ghc/-/commit/20e1c6cc426dcc864c7fc5710b1b5aa25453061c[project @ 2004-01-12 14:36:28 by simonpj]2004-01-12T14:36:31+00:00simonpjunknownWibbles to exporting types abstractlyhttps://gitlab.haskell.org/ghc/ghc/-/commit/f714e6b642fd614a9971717045ae47c3d871275e[project @ 2003-12-30 16:29:17 by simonpj]2003-12-30T16:29:27+00:00simonpjunknown----------------------------
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
inference.
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.https://gitlab.haskell.org/ghc/ghc/-/commit/ac41c500b3769f005eeeaf964170a78c79135196[project @ 2003-11-03 16:00:57 by simonpj]2003-11-03T16:01:03+00:00simonpjunknownWibbles to pretty printing of typeshttps://gitlab.haskell.org/ghc/ghc/-/commit/57573e7e61032482d6be16ed4ac86c2b4115fbfa[project @ 2003-10-30 16:01:49 by simonpj]2003-10-30T16:02:07+00:00simonpjunknownThis 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 thosehttps://gitlab.haskell.org/ghc/ghc/-/commit/ffa4651e23a4c382dd3bdc43674a60b1a91c3b56[project @ 2003-10-10 15:45:04 by simonpj]2003-10-10T15:45:07+00:00simonpjunknownUse tcIsTyVarTy not isTyVarTy; and move isPredTy