summaryrefslogtreecommitdiff
path: root/compiler/hsSyn/HsUtils.lhs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2013-03-04 09:40:56 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2013-03-04 09:40:56 +0000
commitc3ad38d7dc39ef583ddfb586413baa2e57ca3ee8 (patch)
tree421a9452f73247edfd417ffff1220ca653ea0b1e /compiler/hsSyn/HsUtils.lhs
parent3ea331b7f915373e1f8db6000a1a5bb4a63f12f9 (diff)
downloadhaskell-c3ad38d7dc39ef583ddfb586413baa2e57ca3ee8.tar.gz
Rearrange the typechecking of arrows, especially arrow "forms"
The typechecking of arrow forms (in GHC 7.6) is known to be bogus, as described in Trac #5609, because it marches down tuple types that may not yet be fully worked out, depending on when constraint solving happens. Moreover, coercions are generated and simply discarded. The fact that it works at all is a miracle. This refactoring is based on a conversation with Ross, where we rearranged the typing of the argument stack, so that the arrows have the form a (env, (arg1, (arg2, ...(argn, ())))) res rather than a (arg1, (arg2, ...(argn, env))) res as it was before. This is vastly simpler to typecheck; just look at the beautiful, simple type checking of arrow forms now! We need a new HsCmdCast to capture the coercions generated from the argument stack. This leaves us in a better position to tackle the open arrow tickets * Trac #5777 still fails. (I was hoping this patch would cure it.) * Trac #5609 is too complicated for me to grok. Ross? * Trac #344 * Trac #5333
Diffstat (limited to 'compiler/hsSyn/HsUtils.lhs')
-rw-r--r--compiler/hsSyn/HsUtils.lhs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/hsSyn/HsUtils.lhs b/compiler/hsSyn/HsUtils.lhs
index 325bd2e37c..1fa949653e 100644
--- a/compiler/hsSyn/HsUtils.lhs
+++ b/compiler/hsSyn/HsUtils.lhs
@@ -1,4 +1,3 @@
-
%
% (c) The University of Glasgow, 1992-2006
%
@@ -29,7 +28,7 @@ module HsUtils(
mkHsWrap, mkLHsWrap, mkHsWrapCo, mkLHsWrapCo,
coToHsWrapper, mkHsDictLet, mkHsLams,
mkHsOpApp, mkHsDo, mkHsComp, mkHsWrapPat, mkHsWrapPatCo,
- mkLHsPar,
+ mkLHsPar, mkHsCmdCast,
nlHsTyApp, nlHsVar, nlHsLit, nlHsApp, nlHsApps, nlHsIntLit, nlHsVarApps,
nlHsDo, nlHsOpApp, nlHsLam, nlHsPar, nlHsIf, nlHsCase, nlList,
@@ -394,6 +393,10 @@ mkLHsWrapCo :: TcCoercion -> LHsExpr id -> LHsExpr id
mkLHsWrapCo co (L loc e) | isTcReflCo co = L loc e
| otherwise = L loc (mkHsWrap (WpCast co) e)
+mkHsCmdCast :: TcCoercion -> HsCmd id -> HsCmd id
+mkHsCmdCast co cmd | isTcReflCo co = cmd
+ | otherwise = HsCmdCast co cmd
+
coToHsWrapper :: TcCoercion -> HsWrapper
coToHsWrapper co | isTcReflCo co = idHsWrapper
| otherwise = WpCast co