on master help sign in
Support single line where clauses
commitb2f49a76933a156b35110e76fecd06f178a1f102 authorBasile Henry <bjm.henry@gmail.com> dateSat 13 Jul 2019, 18:13 (7 years ago) parent0baa898
2 files changed+6−6
data/examples/declaration/value/function/where-out.hs+1−3 src/Ormolu/Printer/Meat/Declaration/Value.hs+5−3
data/examples/declaration/value/function/where-out.hs+1−3
@@ -1,7 +1,5 @@
11foo :: Int -> Int
2−foo x = f x
3− where
4− f z = z
2+foo x = f x where f z = z
53
64bar :: Int -> Int
75bar x = f x
src/Ormolu/Printer/Meat/Declaration/Value.hs+5−3
@@ -200,11 +200,13 @@ p_match' placer pretty style isInfix strictness m_pats m_grhss = do
200200 then RightArrow
201201 else EqualSign
202202 newlineSep (located' (p_grhs' pretty groupStyle)) grhssGRHSs
203+ let whereLocation = combineSrcSpans patGrhssSpan $ getLoc grhssLocalBinds
203204 unless
204205 (GHC.isEmptyLocalBindsPR (unLoc grhssLocalBinds))
205− (inciLocalBinds $ do
206− newline
207− line (txt "where")
206+ (inciLocalBinds . switchLayout whereLocation $ do
207+ breakpoint
208+ txt "where"
209+ breakpoint
208210 inci (located grhssLocalBinds p_hsLocalBinds)
209211 )
210212 case style of