Fix minor layouting issue with long guards

(see test multiple-clauses-4)
pull/35/head
Lennart Spitzner 2017-03-07 21:43:01 +01:00
parent 00c7384d20
commit 7dc6c525eb
2 changed files with 29 additions and 27 deletions

View File

@ -325,6 +325,30 @@ func (x:+:xr) = x
#test simple guard
func | True = x
#test multiple-clauses-1
func x | x = simple expression
| otherwise = 0
#test multiple-clauses-2
func x
| a somewhat longer guard x = "and a somewhat longer expession that does not"
| otherwise = "fit without putting the guards in new lines"
#test multiple-clauses-3
func x
| very long guard, another rather long guard that refers to x
= nontrivial expression foo bar alsdkjlasdjlasj
| otherwise
= 0
#test multiple-clauses-4
func x
| very loooooooooooooooooooooooooooooong guard
, another rather long guard that refers to x
= nontrivial expression foo bar alsdkjlasdjlasj
| otherwise
= 0
###############################################################################
###############################################################################
@ -443,31 +467,6 @@ func = do
stmt x
###############################################################################
###############################################################################
###############################################################################
#group equations
###############################################################################
###############################################################################
###############################################################################
#test multiple-clauses-1
func x | x = simple expression
| otherwise = 0
#test multiple-clauses-2
func x
| a somewhat longer guard x = "and a somewhat longer expession that does not"
| otherwise = "fit without putting the guards in new lines"
#test multiple-clauses-3
func x
| very long guard, another rather long guard that refers to x
= nontrivial expression foo bar alsdkjlasdjlasj
| otherwise
= 0
###############################################################################
###############################################################################
###############################################################################

View File

@ -356,9 +356,12 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs mWhereDocs =
( case guardDocs of
[] -> []
[g] ->
[docSeq [appSep $ docLit $ Text.pack "|", return g]]
[ docForceSingleline
$ docSeq [appSep $ docLit $ Text.pack "|", return g]
]
gs ->
[ docSeq
[ docForceSingleline
$ docSeq
$ [appSep $ docLit $ Text.pack "|"]
++ List.intersperse docCommaSep (return <$> gs)
]