Improve handling of partial applications involving casts
Improve handling of partial applications involving casts

This patch improves prepareRhs, so that it deals better with casts.

We want to deal well cases like this
	v = (f e1 `cast` co) e2
Here we want to make e1,e2 trivial and get
	x1 = e1; x2 = e2; v = (f x1 `cast` co) v2

This really happens in parser libraries, which wrap functions in newtypes.


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