Fix infix matches with more than 2 args, fixes #219

remotes/felixonmars/release
Lennart Spitzner 2019-09-19 00:48:45 +02:00
parent 6879436e67
commit 0795a39806
2 changed files with 28 additions and 5 deletions

View File

@ -330,6 +330,15 @@ x *** y = x
#test symbol prefix
(***) x y = x
#test infix more args simple
(f >=> g) k = f k >>= g
#test infix more args alignment
(Left a <$$> Left dd) e f = True
(Left a <$$> Right d ) e f = True
(Right a <$$> Left d ) e f = False
(Right a <$$> Right dd) e f = True
###############################################################################
###############################################################################

View File

@ -341,11 +341,25 @@ layoutPatternBind funId binderDoc lmatch@(L _ match) = do
_ -> pure Nothing
let mIdStr' = fixPatternBindIdentifier match <$> mIdStr
patDoc <- docWrapNodePrior lmatch $ case (mIdStr', patDocs) of
(Just idStr, p1 : pr) | isInfix -> docCols
ColPatternsFuncInfix
( [appSep $ docForceSingleline p1, appSep $ docLit idStr]
++ (spacifyDocs $ docForceSingleline <$> pr)
)
(Just idStr, p1:p2:pr) | isInfix -> if null pr
then
docCols ColPatternsFuncInfix
[ appSep $ docForceSingleline p1
, appSep $ docLit $ idStr
, docForceSingleline p2
]
else
docCols ColPatternsFuncInfix
( [docCols ColPatterns
[ docParenL
, appSep $ docForceSingleline p1
, appSep $ docLit $ idStr
, docForceSingleline p2
, appSep $ docParenR
]
]
++ (spacifyDocs $ docForceSingleline <$> pr)
)
(Just idStr, []) -> docLit idStr
(Just idStr, ps) ->
docCols ColPatternsFuncPrefix