on master help sign in
Bang patterns and splices in lambdas
b03f989Vladislav Zavialov
data/examples/declaration/value/function/lambda-single-line-out.hs+6
@@ -7,3 +7,9 @@ bar x =
7
7
8baz :: a -> a -> a
8baz :: a -> a -> a
9baz = \ ~x ~y -> x
9baz = \ ~x ~y -> x
10+
11+zag :: a -> a -> a
12+zag = \ !x !y -> x
13+
14+spl :: a -> a
15+spl = \ $([p|x|]) -> x
data/examples/declaration/value/function/lambda-single-line.hs+6
@@ -7,3 +7,9 @@ bar x =
7
7
8baz :: a -> a -> a
8baz :: a -> a -> a
9baz = \ ~x ~y -> x
9baz = \ ~x ~y -> x
10+
11+zag :: a -> a -> a
12+zag = \ !x !y -> x
13+
14+spl :: a -> a
15+spl = \ $([p|x|]) -> x
src/Ormolu/Printer/Meat/Declaration/Value.hs+6−3
@@ -135,9 +135,12 @@ p_match' placer pretty style isInfix m_pats m_grhss = do
135 PatternBind -> stdCase
135 PatternBind -> stdCase
136 Case -> stdCase
136 Case -> stdCase
137 Lambda -> do
137 Lambda -> do
138− case unLoc (NE.head ne_pats) of
138+ let needsSpace = case unLoc (NE.head ne_pats) of
139− LazyPat _ _ -> txt "\\ "
139+ LazyPat _ _ -> True
140− _ -> txt "\\"
140+ BangPat _ _ -> True
141+ SplicePat _ _ -> True
142+ _ -> False
143+ txt (if needsSpace then "\\ " else "\\")
141 stdCase
144 stdCase
142 LambdaCase -> stdCase
145 LambdaCase -> stdCase
143 return inci'
146 return inci'