Allow special layout for HsApp with HsDo/HsSpiceE args

ghc92
Lennart Spitzner 2023-04-29 10:08:01 +00:00
parent ab67a794db
commit 884c7da97c
3 changed files with 37 additions and 18 deletions

View File

@ -306,15 +306,14 @@ parserCompactLocation =
[ try
$ [ ParseRelAbs (Text.Read.read digits) _ _
| digits <- many1 digit
, rel1 :: Maybe (Either Int (Ratio Int)) <-
optionMaybe
[ case divPart of
Nothing -> Left $ Text.Read.read digits
Just ddigits ->
Right $ Text.Read.read digits % Text.Read.read ddigits
| digits <- many1 digit
, divPart <- optionMaybe (string "/" *> many1 digit)
]
, rel1 :: Maybe (Either Int (Ratio Int)) <- optionMaybe
[ case divPart of
Nothing -> Left $ Text.Read.read digits
Just ddigits ->
Right $ Text.Read.read digits % Text.Read.read ddigits
| digits <- many1 digit
, divPart <- optionMaybe (string "/" *> many1 digit)
]
]
]
@ -938,3 +937,22 @@ tzejubuVxairoy
-- foo bar
=> CUR.Ozuzcak zub
-> m ()
#test allow par-spacing for HsApp HsDo
func = other $ meep
do
abc
def
(some other very long linnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnne)
#test allow par-spacing for HsApp HsDo
func = other $ meep
[ x | x <- myList ]
(some other very long linnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnne)
#test allow par-spacing for HsApp HsSpliceE
{-# LANGUAGE QuasiQuotes #-}
func = other $ meep
[q|hello
world|]
(some other very long linnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnne)

View File

@ -1252,15 +1252,14 @@ parserCompactLocation =
[ try
$ [ ParseRelAbs (Text.Read.read digits) _ _
| digits <- many1 digit
, rel1 :: Maybe (Either Int (Ratio Int)) <-
optionMaybe
[ case divPart of
Nothing -> Left $ Text.Read.read digits
Just ddigits ->
Right $ Text.Read.read digits % Text.Read.read ddigits
| digits <- many1 digit
, divPart <- optionMaybe (string "/" *> many1 digit)
]
, rel1 :: Maybe (Either Int (Ratio Int)) <- optionMaybe
[ case divPart of
Nothing -> Left $ Text.Read.read digits
Just ddigits ->
Right $ Text.Read.read digits % Text.Read.read ddigits
| digits <- many1 digit
, divPart <- optionMaybe (string "/" *> many1 digit)
]
]
]

View File

@ -194,6 +194,8 @@ layoutExpr lexpr@(L _ expr) = do
(_, L _ ExplicitTuple{}) -> True
(_, L _ ExplicitList{}) -> True
(_, L _ HsPar{}) -> True
(_, L _ HsDo{}) -> True
(_, L _ HsSpliceE{}) -> True
_ -> False
let wrap = if all checkAllowPar paramEs then docSetParSpacing else id
wrap $ docAddBaseY BrIndentRegular $ docPar