Fix parentheses for tyApp. (#40)

This commit is contained in:
Judah Jacobson 2019-08-25 14:32:00 -07:00 committed by GitHub
parent 0b726749a2
commit 3af6da1152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -126,14 +126,15 @@ e @::@ t = ExprWithTySig (builtLoc e) (sigWcType t)
-- > var "f" @@ var "Int"
tyApp :: HsExpr' -> HsType' -> HsExpr'
#if MIN_VERSION_ghc(8,8,0)
tyApp e t = noExt HsAppType (builtLoc e) t'
tyApp e t = noExt HsAppType e' t'
#elif MIN_VERSION_ghc(8,6,0)
tyApp e t = HsAppType t' (builtLoc e)
tyApp e t = HsAppType t' e'
#else
tyApp e t = HsAppType (builtLoc e) t'
tyApp e t = HsAppType e' t'
#endif
where
t' = wcType $ unLoc $ parenthesizeTypeForApp $ builtLoc t
e' = parenthesizeExprForApp $ builtLoc e
-- | Constructs a record with explicit field names.
--

View File

@ -195,6 +195,11 @@ exprsTest dflags = testGroup "Expr"
-- TODO: add more tests.
[ "do (let x = 1 in x)" :~ do' [stmt $ let' [valBind "x" (int 1)] (var "x")]
]
, test "tyApp"
[ "x @t" :~ var "x" `tyApp` var "t"
, "(f x) @t" :~ (var "f" @@ var "x") `tyApp` var "t"
, "f x @t" :~ var "f" @@ (var "x" `tyApp` var "t")
]
]
where
test = testExprs dflags