Merge pull request #82 from matthew-piziak/tuple-section-support

Tuple section support (fixes #41)
pull/95/head
Lennart Spitzner 2017-12-15 00:49:57 +01:00 committed by GitHub
commit 9700fb2a50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View File

@ -476,9 +476,23 @@ func = (`abc` 1)
#group tuples #group tuples
### ###
#test 1 #test pair
func = (abc, def) func = (abc, def)
#test pair section left
func = (abc, )
#test pair section right
func = (, abc)
#test quintuple section long
myTupleSection =
( verylaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaargefirstelement
,
, verylaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaargethirdelement
,
)
#test 2 #test 2
#pending #pending
func = (lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd func = (lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd

View File

@ -341,9 +341,9 @@ layoutExpr lexpr@(L _ expr) = do
opDoc <- docSharedWrapper layoutExpr op opDoc <- docSharedWrapper layoutExpr op
rightDoc <- docSharedWrapper layoutExpr right rightDoc <- docSharedWrapper layoutExpr right
docSeq [opDoc, docSeparator, rightDoc] docSeq [opDoc, docSeparator, rightDoc]
ExplicitTuple args boxity ExplicitTuple args boxity -> do
| Just argExprs <- args `forM` (\case (L _ (Present e)) -> Just e; _ -> Nothing) -> do let argExprs = fmap (\case (L _ (Present e)) -> Just e; (L _ (Missing PlaceHolder)) -> Nothing) args
argDocs <- docSharedWrapper layoutExpr `mapM` argExprs argDocs <- docSharedWrapper (maybe docEmpty layoutExpr) `mapM` argExprs
hasComments <- hasAnyCommentsBelow lexpr hasComments <- hasAnyCommentsBelow lexpr
let (openLit, closeLit) = case boxity of let (openLit, closeLit) = case boxity of
Boxed -> (docLit $ Text.pack "(", docLit $ Text.pack ")") Boxed -> (docLit $ Text.pack "(", docLit $ Text.pack ")")
@ -385,8 +385,6 @@ layoutExpr lexpr@(L _ expr) = do
end = closeLit end = closeLit
in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN] ++ [end] in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN] ++ [end]
] ]
ExplicitTuple{} ->
unknownNodeError "ExplicitTuple|.." lexpr
HsCase cExp (MG lmatches@(L _ matches) _ _ _) -> do HsCase cExp (MG lmatches@(L _ matches) _ _ _) -> do
cExpDoc <- docSharedWrapper layoutExpr cExp cExpDoc <- docSharedWrapper layoutExpr cExp
binderDoc <- docLit $ Text.pack "->" binderDoc <- docLit $ Text.pack "->"