1
1
mirror of https://github.com/google/ormolu.git synced 2024-12-02 23:43:34 +03:00

Bang patterns and splices in lambdas

This commit is contained in:
Vladislav Zavialov 2019-07-12 12:38:42 +03:00 committed by Mark Karpov
parent a7265df09e
commit b03f989f36
3 changed files with 18 additions and 3 deletions

View File

@ -7,3 +7,9 @@ bar x =
baz :: a -> a -> a
baz = \ ~x ~y -> x
zag :: a -> a -> a
zag = \ !x !y -> x
spl :: a -> a
spl = \ $([p|x|]) -> x

View File

@ -7,3 +7,9 @@ bar x =
baz :: a -> a -> a
baz = \ ~x ~y -> x
zag :: a -> a -> a
zag = \ !x !y -> x
spl :: a -> a
spl = \ $([p|x|]) -> x

View File

@ -135,9 +135,12 @@ p_match' placer pretty style isInfix m_pats m_grhss = do
PatternBind -> stdCase
Case -> stdCase
Lambda -> do
case unLoc (NE.head ne_pats) of
LazyPat _ _ -> txt "\\ "
_ -> txt "\\"
let needsSpace = case unLoc (NE.head ne_pats) of
LazyPat _ _ -> True
BangPat _ _ -> True
SplicePat _ _ -> True
_ -> False
txt (if needsSpace then "\\ " else "\\")
stdCase
LambdaCase -> stdCase
return inci'