Fix problem of do notation as left argument of an operator
parent
86c25ff315
commit
5c64928972
|
@ -877,3 +877,10 @@ instance HasDependencies SomeDataModel where
|
||||||
-- between these data models or whatever.
|
-- between these data models or whatever.
|
||||||
type Dependencies SomeDataModel
|
type Dependencies SomeDataModel
|
||||||
= (SomeOtherDataModelId, SomeOtherOtherDataModelId)
|
= (SomeOtherDataModelId, SomeOtherOtherDataModelId)
|
||||||
|
|
||||||
|
#test stupid-do-operator-combination
|
||||||
|
|
||||||
|
func =
|
||||||
|
do
|
||||||
|
y
|
||||||
|
>>= x
|
||||||
|
|
|
@ -426,6 +426,9 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
(_, L _ (HsApp _ (L _ HsVar{}))) -> False
|
(_, L _ (HsApp _ (L _ HsVar{}))) -> False
|
||||||
_ -> True
|
_ -> True
|
||||||
#endif
|
#endif
|
||||||
|
let leftIsDoBlock = case expLeft of
|
||||||
|
L _ HsDo{} -> True
|
||||||
|
_ -> False
|
||||||
runFilteredAlternative $ do
|
runFilteredAlternative $ do
|
||||||
-- one-line
|
-- one-line
|
||||||
addAlternative
|
addAlternative
|
||||||
|
@ -442,16 +445,17 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
-- , docSetBaseY $ docAddBaseY BrIndentRegular expDocRight
|
-- , docSetBaseY $ docAddBaseY BrIndentRegular expDocRight
|
||||||
-- ]
|
-- ]
|
||||||
-- two-line
|
-- two-line
|
||||||
addAlternative
|
addAlternative $ do
|
||||||
$ docAddBaseY BrIndentRegular
|
let
|
||||||
$ docPar
|
expDocOpAndRight = docForceSingleline
|
||||||
expDocLeft -- TODO: this is not forced to single-line, which has
|
|
||||||
-- certain.. interesting consequences.
|
|
||||||
-- At least, the "two-line" label is not entirely
|
|
||||||
-- accurate.
|
|
||||||
( docForceSingleline
|
|
||||||
$ docCols ColOpPrefix [appSep $ expDocOp, docSetBaseY expDocRight]
|
$ docCols ColOpPrefix [appSep $ expDocOp, docSetBaseY expDocRight]
|
||||||
)
|
if leftIsDoBlock
|
||||||
|
then docLines [expDocLeft, expDocOpAndRight]
|
||||||
|
else docAddBaseY BrIndentRegular $ docPar expDocLeft expDocOpAndRight
|
||||||
|
-- TODO: in both cases, we don't force expDocLeft to be
|
||||||
|
-- single-line, which has certain.. interesting consequences.
|
||||||
|
-- At least, the "two-line" label is not entirely
|
||||||
|
-- accurate.
|
||||||
-- one-line + par
|
-- one-line + par
|
||||||
addAlternativeCond allowPar
|
addAlternativeCond allowPar
|
||||||
$ docSeq
|
$ docSeq
|
||||||
|
@ -460,11 +464,13 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
, docForceParSpacing expDocRight
|
, docForceParSpacing expDocRight
|
||||||
]
|
]
|
||||||
-- more lines
|
-- more lines
|
||||||
addAlternative
|
addAlternative $ do
|
||||||
$ docAddBaseY BrIndentRegular
|
let expDocOpAndRight =
|
||||||
$ docPar
|
docCols ColOpPrefix [appSep expDocOp, docSetBaseY expDocRight]
|
||||||
expDocLeft
|
if leftIsDoBlock
|
||||||
(docCols ColOpPrefix [appSep expDocOp, docSetBaseY expDocRight])
|
then docLines [expDocLeft, expDocOpAndRight]
|
||||||
|
else docAddBaseY BrIndentRegular
|
||||||
|
$ docPar expDocLeft expDocOpAndRight
|
||||||
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
|
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
|
||||||
NegApp _ op _ -> do
|
NegApp _ op _ -> do
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue