[project @ 2002-02-14 15:03:38 by simonpj] ------------------------------------ 	Desugar existential matches correctly 	------------------------------------
[project @ 2002-02-14 15:03:38 by simonpj]
------------------------------------
	Desugar existential matches correctly
	------------------------------------

Consider
	data T = forall a. Ord a => T a (a->Int)

	f (T x f) True  = ...expr1...
	f (T y g) False = ...expr2..

When we put in the tyvars etc we get

	f (T a (d::Ord a) (x::a) (f::a->Int)) True =  ...expr1...
	f (T b (e::Ord a) (y::a) (g::a->Int)) True =  ...expr2...

After desugaring etc we'll get a single case:

	f = \t::T b::Bool ->
	    case t of
	       T a (d::Ord a) (x::a) (f::a->Int)) ->
	    case b of
		True  -> ...expr1...
		False -> ...expr2...

*** We have to substitute [a/b, d/e] in expr2! **


Originally I tried to use
	(\b -> let e = d in expr2) a
to do this substitution.  While this is "correct" in a way, it fails
Lint, because e::Ord b but d::Ord a.

So now I simply do the substitution properly using substExpr.

olsner/ghc,vTurbine/ghc,nomeata/ghc,ghc-android/ghc,gridaphobe/ghc,ml9951/ghc,ilyasergey/GHC-XAppFix,elieux/ghc,sdiehl/ghc,siddhanathan/ghc,green-haskell/ghc,green-haskell/ghc,urbanslug/ghc,siddhanathan/ghc,TomMD/ghc,tjakway/ghcjvm,oldmanmike/ghc,elieux/ghc,anton-dessiatov/ghc,ml9951/ghc,mcschroeder/ghc,siddhanathan/ghc,nomeata/ghc,holzensp/ghc,tibbe/ghc,wxwxwwxxx/ghc,ilyasergey/GHC-XAppFix,GaloisInc/halvm-ghc,gridaphobe/ghc,lukexi/ghc,nkaretnikov/ghc,urbanslug/ghc,da-x/ghc,ezyang/ghc,oldmanmike/ghc,ml9951/ghc,ryantm/ghc,mcmaniac/ghc,nushio3/ghc,jstolarek/ghc,AlexanderPankiv/ghc,vikraman/ghc,nkaretnikov/ghc,ilyasergey/GHC-XAppFix,forked-upstream-packages-for-ghcjs/ghc,ezyang/ghc,ryantm/ghc,jstolarek/ghc,anton-dessiatov/ghc,ekmett/ghc,acowley/ghc,wxwxwwxxx/ghc,mettekou/ghc,vTurbine/ghc,jstolarek/ghc,frantisekfarka/ghc-dsi,gridaphobe/ghc,da-x/ghc,vTurbine/ghc,AlexanderPankiv/ghc,oldmanmike/ghc,nomeata/ghc,mcmaniac/ghc,nathyong/microghc-ghc,gcampax/ghc,acowley/ghc,tibbe/ghc,nathyong/microghc-ghc,TomMD/ghc,mcschroeder/ghc,wxwxwwxxx/ghc,gcampax/ghc,forked-upstream-packages-for-ghcjs/ghc,ezyang/ghc,ghc-android/ghc,ryantm/ghc,holzensp/ghc,mettekou/ghc,bitemyapp/ghc,hferreiro/replay,acowley/ghc,elieux/ghc,olsner/ghc,bitemyapp/ghc,frantisekfarka/ghc-dsi,vikraman/ghc,shlevy/ghc,anton-dessiatov/ghc,frantisekfarka/ghc-dsi,nkaretnikov/ghc,lukexi/ghc,vikraman/ghc,fmthoma/ghc,mettekou/ghc,tjakway/ghcjvm,vikraman/ghc,nathyong/microghc-ghc,elieux/ghc,AlexanderPankiv/ghc,mcschroeder/ghc,ml9951/ghc,da-x/ghc,nushio3/ghc,wxwxwwxxx/ghc,anton-dessiatov/ghc,ml9951/ghc,elieux/ghc,mfine/ghc,mcmaniac/ghc,holzensp/ghc,vikraman/ghc,siddhanathan/ghc,hferreiro/replay,gcampax/ghc,urbanslug/ghc,mettekou/ghc,sdiehl/ghc,tibbe/ghc,da-x/ghc,frantisekfarka/ghc-dsi,fmthoma/ghc,ryantm/ghc,da-x/ghc,nushio3/ghc,sdiehl/ghc,shlevy/ghc,ekmett/ghc,AlexanderPankiv/ghc,nathyong/microghc-ghc,holzensp/ghc,ekmett/ghc,fmthoma/ghc,gcampax/ghc,green-haskell/ghc,acowley/ghc,green-haskell/ghc,AlexanderPankiv/ghc,lukexi/ghc-7.8-arm64,olsner/ghc,ml9951/ghc,sgillespie/ghc,TomMD/ghc,shlevy/ghc,mettekou/ghc,tjakway/ghcjvm,ghc-android/ghc,wxwxwwxxx/ghc,jstolarek/ghc,nomeata/ghc,ml9951/ghc,hferreiro/replay,ekmett/ghc,olsner/ghc,oldmanmike/ghc,GaloisInc/halvm-ghc,gcampax/ghc,mcschroeder/ghc,gcampax/ghc,elieux/ghc,gridaphobe/ghc,mettekou/ghc,frantisekfarka/ghc-dsi,da-x/ghc,anton-dessiatov/ghc,vTurbine/ghc,urbanslug/ghc,snoyberg/ghc,nathyong/microghc-ghc,bitemyapp/ghc,nushio3/ghc,ryantm/ghc,tjakway/ghcjvm,TomMD/ghc,ezyang/ghc,lukexi/ghc-7.8-arm64,GaloisInc/halvm-ghc,lukexi/ghc-7.8-arm64,tjakway/ghcjvm,TomMD/ghc,bitemyapp/ghc,urbanslug/ghc,wxwxwwxxx/ghc,christiaanb/ghc,vTurbine/ghc,fmthoma/ghc,gcampax/ghc,fmthoma/ghc,nushio3/ghc,vikraman/ghc,TomMD/ghc,nkaretnikov/ghc,acowley/ghc,sdiehl/ghc,forked-upstream-packages-for-ghcjs/ghc,christiaanb/ghc,shlevy/ghc,gridaphobe/ghc,ml9951/ghc,christiaanb/ghc,sgillespie/ghc,sdiehl/ghc,mfine/ghc,christiaanb/ghc,christiaanb/ghc,oldmanmike/ghc,hferreiro/replay,wxwxwwxxx/ghc,green-haskell/ghc,mcmaniac/ghc,acowley/ghc,vTurbine/ghc,snoyberg/ghc,sdiehl/ghc,hferreiro/replay,mfine/ghc,mfine/ghc,olsner/ghc,spacekitteh/smcghc,nathyong/microghc-ghc,sgillespie/ghc,urbanslug/ghc,nushio3/ghc,mcschroeder/ghc,oldmanmike/ghc,sgillespie/ghc,holzensp/ghc,ilyasergey/GHC-XAppFix,vTurbine/ghc,ezyang/ghc,GaloisInc/halvm-ghc,forked-upstream-packages-for-ghcjs/ghc,AlexanderPankiv/ghc,mcmaniac/ghc,urbanslug/ghc,sgillespie/ghc,olsner/ghc,tibbe/ghc,anton-dessiatov/ghc,nkaretnikov/ghc,shlevy/ghc,nushio3/ghc,lukexi/ghc-7.8-arm64,lukexi/ghc,ghc-android/ghc,mfine/ghc,sgillespie/ghc,snoyberg/ghc,elieux/ghc,shlevy/ghc,tjakway/ghcjvm,mfine/ghc,ezyang/ghc,siddhanathan/ghc,sgillespie/ghc,lukexi/ghc-7.8-arm64,christiaanb/ghc,forked-upstream-packages-for-ghcjs/ghc,snoyberg/ghc,olsner/ghc,lukexi/ghc,tibbe/ghc,ghc-android/ghc,nomeata/ghc,spacekitteh/smcghc,ghc-android/ghc,mcschroeder/ghc,fmthoma/ghc,ezyang/ghc,anton-dessiatov/ghc,tjakway/ghcjvm,siddhanathan/ghc,vikraman/ghc,hferreiro/replay,snoyberg/ghc,bitemyapp/ghc,lukexi/ghc,nkaretnikov/ghc,jstolarek/ghc,snoyberg/ghc,mfine/ghc,shlevy/ghc,forked-upstream-packages-for-ghcjs/ghc,gridaphobe/ghc,oldmanmike/ghc,spacekitteh/smcghc,christiaanb/ghc,mcschroeder/ghc,fmthoma/ghc,mettekou/ghc,ekmett/ghc,spacekitteh/smcghc,hferreiro/replay,AlexanderPankiv/ghc,sdiehl/ghc,forked-upstream-packages-for-ghcjs/ghc,TomMD/ghc,da-x/ghc,gridaphobe/ghc,acowley/ghc,GaloisInc/halvm-ghc,spacekitteh/smcghc,ghc-android/ghc,snoyberg/ghc,nkaretnikov/ghc,nathyong/microghc-ghc,GaloisInc/halvm-ghc,GaloisInc/halvm-ghc,siddhanathan/ghc