Prevent type applications from gluing to TH splices that follow them
commitcc337bda18c6851296b8ffd63d2e28e10b6441c7
authorMark Karpov <markkarpov92@gmail.com>
dateMon 15 Jun 2020, 11:52 (6 years ago)
parenta877785
CHANGELOG.md+3
@@ -22,6 +22,9 @@
2222* Blank lines between definitions in `let` and `while` bindings are now
2323 preserved. [Issue 554](https://github.com/tweag/ormolu/issues/554).
2424
25+* Fixed the bug when type applications glued to TH splices that followed
26+ them. [Issue 613](https://github.com/tweag/ormolu/issues/613).
27+
2528## Ormolu 0.1.0.0
2629
2730* Fixed rendering of type signatures concerning several identifiers. [Issue
data/examples/declaration/value/function/type-applications-and-splice-out.hsnew file+4
@@ -0,0 +1,4 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+{-# LANGUAGE TypeApplications #-}
3+
4+staticKey name = [|sing @ $(symFQN name)|]
data/examples/declaration/value/function/type-applications-and-splice.hsnew file+4
@@ -0,0 +1,4 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+{-# LANGUAGE TypeApplications #-}
3+
4+staticKey name = [| sing @ $(symFQN name) |]
src/Ormolu/Printer/Meat/Declaration/Value.hs+5
@@ -613,6 +613,11 @@ p_hsExpr' s = \case
613613 breakpoint
614614 inci $ do
615615 txt "@"
616+ -- Insert a space when the type is represented as a TH splice to avoid
617+ -- gluing @ and $ together.
618+ case unLoc (hswc_body a) of
619+ HsSpliceTy {} -> space
620+ _ -> return ()
616621 located (hswc_body a) p_hsType
617622 OpApp NoExtField x op y -> do
618623 let opTree = OpBranch (exprOpTree x) op (exprOpTree y)