Commit 67c2b6a1 authored by's avatar
Browse files

Simplify desugaring of left sections

	MERGE TO 6.6 branch!

Some while ago I made the type checker a tiny bit more lenient about
left sections, so that 
	(x !)
would typecheck iff
	((!) x) 

Strictly, Haskell 98 requires that the section typechecks iff
	(\y. (!) x y)
typechecks, and I should really have made the relaxation dependent on a 
flag, but I didn't.

Anyway, this commit fixes the *desugarer* so that it correctly desugars
the programs that the typechecker passes.
parent 38f4f2e0
......@@ -281,20 +281,10 @@ dsExpr (OpApp e1 op _ e2)
dsLExpr e2 `thenDs` \ y_core ->
returnDs (mkApps core_op [x_core, y_core])
dsExpr (SectionL expr op)
= dsLExpr op `thenDs` \ core_op ->
-- for the type of y, we need the type of op's 2nd argument
(x_ty:y_ty:_, _) = splitFunTys (exprType core_op)
-- Must look through an implicit-parameter type;
-- newtype impossible; hence Type.splitFunTys
dsLExpr expr `thenDs` \ x_core ->
newSysLocalDs x_ty `thenDs` \ x_id ->
newSysLocalDs y_ty `thenDs` \ y_id ->
returnDs (bindNonRec x_id x_core $
Lam y_id (mkApps core_op [Var x_id, Var y_id]))
dsExpr (SectionL expr op) -- Desugar (e !) to ((!) e)
= dsLExpr op `thenDs` \ core_op ->
dsLExpr expr `thenDs` \ x_core ->
returnDs (App core_op x_core)
-- dsLExpr (SectionR op expr) -- \ x -> op x expr
dsExpr (SectionR op expr)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment