- = do { (op', [arg1']) <- tcApp op 1 (tcArgs lop [arg1]) res_ty
- ; return (SectionL arg1' (L loc op')) }
+ = do dflags <- getDOpts
+ if dopt Opt_PostfixOperators dflags
+ then do (op', [arg1']) <- tcApp op 1 (tcArgs lop [arg1]) res_ty
+ return (SectionL arg1' (L loc op'))
+ else do (co_fn, (op', arg1'))
+ <- subFunTys doc 1 res_ty
+ $ \ [arg2_ty'] res_ty' ->
+ tcApp op 2 (tc_args arg2_ty') res_ty'
+ return (mkHsWrap co_fn (SectionL arg1' (L loc op')))
+ where
+ doc = ptext (sLit "The section") <+> quotes (ppr in_expr)
+ <+> ptext (sLit "takes one argument")
+ tc_args arg2_ty' qtvs qtys [arg1_ty, arg2_ty]
+ = do { boxyUnify arg2_ty' (substTyWith qtvs qtys arg2_ty)
+ ; arg1' <- tcArg lop 2 arg1 qtvs qtys arg1_ty
+ ; qtys' <- mapM refineBox qtys -- c.f. tcArgs
+ ; return (qtys', arg1') }
+ tc_args _ _ _ _ = panic "tcExpr SectionL"