[project @ 2002-04-01 08:23:30 by simonpj]
authorsimonpj <unknown>
Mon, 1 Apr 2002 08:23:36 +0000 (08:23 +0000)
committersimonpj <unknown>
Mon, 1 Apr 2002 08:23:36 +0000 (08:23 +0000)
commit9003a18c4efa4548ae80709aef9963f7b544ded3
treeda2fd1a1dc367b6bb86dfa6e473038fb2cc400ce
parent7f9f2f0a0b571a3fd55af7c85d662d08c5b3f0e3
[project @ 2002-04-01 08:23:30 by simonpj]
------------------------------------
Change the treatment of the stupid
   context on data constructors
-----------------------------------

Data types can have a context:

data (Eq a, Ord b) => T a b = T1 a b | T2 a

and that makes the constructors have a context too
(notice that T2's context is "thinned"):

T1 :: (Eq a, Ord b) => a -> b -> T a b
T2 :: (Eq a) => a -> T a b

Furthermore, this context pops up when pattern matching
(though GHC hasn't implemented this, but it is in H98, and
I've fixed GHC so that it now does):

f (T2 x) = x
gets inferred type
f :: Eq a => T a b -> a

I say the context is "stupid" because the dictionaries passed
are immediately discarded -- they do nothing and have no benefit.
It's a flaw in the language.

Up to now I have put this stupid context into the type of
the "wrapper" constructors functions, T1 and T2, but that turned
out to be jolly inconvenient for generics, and record update, and
other functions that build values of type T (because they don't
have suitable dictionaries available).

So now I've taken the stupid context out.  I simply deal with
it separately in the type checker on occurrences of a constructor,
either in an expression or in a pattern.

To this end

* Lots of changes in DataCon, MkId

* New function Inst.tcInstDataCon to instantiate a data constructor

I also took the opportunity to

* Rename
dataConId --> dataConWorkId
  for consistency.

* Tidied up MkId.rebuildConArgs quite a bit, and renamed it
mkReboxingAlt

* Add function DataCon.dataConExistentialTyVars, with the obvious meaning
27 files changed:
ghc/compiler/basicTypes/DataCon.lhs
ghc/compiler/basicTypes/MkId.lhs
ghc/compiler/basicTypes/Unique.lhs
ghc/compiler/codeGen/CgCon.lhs
ghc/compiler/coreSyn/CorePrep.lhs
ghc/compiler/coreSyn/CoreSyn.lhs
ghc/compiler/coreSyn/MkExternalCore.lhs
ghc/compiler/deSugar/DsExpr.lhs
ghc/compiler/deSugar/DsUtils.lhs
ghc/compiler/hsSyn/HsExpr.lhs
ghc/compiler/javaGen/JavaGen.lhs
ghc/compiler/main/HscTypes.lhs
ghc/compiler/main/MkIface.lhs
ghc/compiler/prelude/PrelRules.lhs
ghc/compiler/prelude/TysWiredIn.lhs
ghc/compiler/rename/RnSource.lhs
ghc/compiler/simplCore/SimplUtils.lhs
ghc/compiler/typecheck/Inst.lhs
ghc/compiler/typecheck/TcClassDcl.lhs
ghc/compiler/typecheck/TcDeriv.lhs
ghc/compiler/typecheck/TcExpr.lhs
ghc/compiler/typecheck/TcHsSyn.lhs
ghc/compiler/typecheck/TcIfaceSig.lhs
ghc/compiler/typecheck/TcMonad.lhs
ghc/compiler/typecheck/TcPat.lhs
ghc/compiler/typecheck/TcTyDecls.lhs
ghc/compiler/types/Generics.lhs