mirror of
https://github.com/google/ormolu.git
synced 2024-12-02 23:43:34 +03:00
Keep FunBind strictness
This commit is contained in:
parent
63f4d1f4f4
commit
984e4b674f
@ -0,0 +1,3 @@
|
|||||||
|
!a = ()
|
||||||
|
|
||||||
|
~b = ()
|
@ -0,0 +1,2 @@
|
|||||||
|
!a = ()
|
||||||
|
~b = ()
|
@ -56,7 +56,7 @@ p_valDecl = line . p_valDecl'
|
|||||||
p_valDecl' :: HsBindLR GhcPs GhcPs -> R ()
|
p_valDecl' :: HsBindLR GhcPs GhcPs -> R ()
|
||||||
p_valDecl' = \case
|
p_valDecl' = \case
|
||||||
FunBind NoExt funId funMatches _ _ -> p_funBind funId funMatches
|
FunBind NoExt funId funMatches _ _ -> p_funBind funId funMatches
|
||||||
PatBind NoExt pat grhss _ -> p_match PatternBind False [pat] grhss
|
PatBind NoExt pat grhss _ -> p_match PatternBind False NoSrcStrict [pat] grhss
|
||||||
VarBind {} -> notImplemented "VarBinds" -- introduced by the type checker
|
VarBind {} -> notImplemented "VarBinds" -- introduced by the type checker
|
||||||
AbsBinds {} -> notImplemented "AbsBinds" -- introduced by the type checker
|
AbsBinds {} -> notImplemented "AbsBinds" -- introduced by the type checker
|
||||||
PatSynBind NoExt psb -> p_patSynBind psb
|
PatSynBind NoExt psb -> p_patSynBind psb
|
||||||
@ -85,12 +85,19 @@ p_matchGroup'
|
|||||||
p_matchGroup' placer pretty style MG {..} =
|
p_matchGroup' placer pretty style MG {..} =
|
||||||
locatedVia Nothing mg_alts $
|
locatedVia Nothing mg_alts $
|
||||||
newlineSep (located' (\m@Match {..} ->
|
newlineSep (located' (\m@Match {..} ->
|
||||||
p_match' placer pretty style (isInfixMatch m) m_pats m_grhss))
|
p_match' placer pretty style (isInfixMatch m) (matchStrictness m) m_pats m_grhss))
|
||||||
p_matchGroup' _ _ _ (XMatchGroup NoExt) = notImplemented "XMatchGroup"
|
p_matchGroup' _ _ _ (XMatchGroup NoExt) = notImplemented "XMatchGroup"
|
||||||
|
|
||||||
|
matchStrictness :: Match id body -> SrcStrictness
|
||||||
|
matchStrictness match =
|
||||||
|
case m_ctxt match of
|
||||||
|
FunRhs{mc_strictness=s} -> s
|
||||||
|
_ -> NoSrcStrict
|
||||||
|
|
||||||
p_match
|
p_match
|
||||||
:: MatchGroupStyle
|
:: MatchGroupStyle
|
||||||
-> Bool -- ^ Is this an infix match?
|
-> Bool -- ^ Is this an infix match?
|
||||||
|
-> SrcStrictness -- ^ Strictness prefix (FunBind)
|
||||||
-> [LPat GhcPs]
|
-> [LPat GhcPs]
|
||||||
-> GRHSs GhcPs (LHsExpr GhcPs)
|
-> GRHSs GhcPs (LHsExpr GhcPs)
|
||||||
-> R ()
|
-> R ()
|
||||||
@ -102,10 +109,11 @@ p_match'
|
|||||||
-> (body -> R ())
|
-> (body -> R ())
|
||||||
-> MatchGroupStyle
|
-> MatchGroupStyle
|
||||||
-> Bool -- ^ Is this an infix match?
|
-> Bool -- ^ Is this an infix match?
|
||||||
|
-> SrcStrictness -- ^ Strictness prefix (FunBind)
|
||||||
-> [LPat GhcPs]
|
-> [LPat GhcPs]
|
||||||
-> GRHSs GhcPs (Located body)
|
-> GRHSs GhcPs (Located body)
|
||||||
-> R ()
|
-> R ()
|
||||||
p_match' placer pretty style isInfix m_pats m_grhss = do
|
p_match' placer pretty style isInfix strictness m_pats m_grhss = do
|
||||||
-- NOTE Normally, since patterns may be placed in a multi-line layout, it
|
-- NOTE Normally, since patterns may be placed in a multi-line layout, it
|
||||||
-- is necessary to bump indentation for the pattern group so it's more
|
-- is necessary to bump indentation for the pattern group so it's more
|
||||||
-- indented than function name. This in turn means that indentation for
|
-- indented than function name. This in turn means that indentation for
|
||||||
@ -113,6 +121,10 @@ p_match' placer pretty style isInfix m_pats m_grhss = do
|
|||||||
-- would start with two indentation steps applied, which is ugly, so we
|
-- would start with two indentation steps applied, which is ugly, so we
|
||||||
-- need to be a bit more clever here and bump indentation level only when
|
-- need to be a bit more clever here and bump indentation level only when
|
||||||
-- pattern group is multiline.
|
-- pattern group is multiline.
|
||||||
|
case strictness of
|
||||||
|
NoSrcStrict -> return ()
|
||||||
|
SrcStrict -> txt "!"
|
||||||
|
SrcLazy -> txt "~"
|
||||||
inci' <- case NE.nonEmpty m_pats of
|
inci' <- case NE.nonEmpty m_pats of
|
||||||
Nothing -> id <$ case style of
|
Nothing -> id <$ case style of
|
||||||
Function name -> p_rdrName name
|
Function name -> p_rdrName name
|
||||||
|
Loading…
Reference in New Issue
Block a user