Improve tuple layouting (also fixes #18 for tuples)
parent
f6324da600
commit
ca42178eff
|
@ -752,6 +752,16 @@ autocheckCases =
|
||||||
, ("Consistent Result", alwaysSame) -- already representative
|
, ("Consistent Result", alwaysSame) -- already representative
|
||||||
]
|
]
|
||||||
|
|
||||||
|
#test issue 18b
|
||||||
|
autocheckCases =
|
||||||
|
[ ("Never Deadlocks", representative deadlocksNever)
|
||||||
|
, ("No Exceptions" , representative exceptionsNever)
|
||||||
|
, ( "Consistent Result"
|
||||||
|
, alwaysSame -- already representative
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -283,20 +283,46 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
ExplicitTuple args boxity
|
ExplicitTuple args boxity
|
||||||
| Just argExprs <- args `forM` (\case (L _ (Present e)) -> Just e; _ -> Nothing) -> do
|
| Just argExprs <- args `forM` (\case (L _ (Present e)) -> Just e; _ -> Nothing) -> do
|
||||||
argDocs <- docSharedWrapper layoutExpr `mapM` argExprs
|
argDocs <- docSharedWrapper layoutExpr `mapM` argExprs
|
||||||
case boxity of
|
hasComments <- hasAnyCommentsBelow lexpr
|
||||||
Boxed -> docAlt
|
let (openLit, closeLit) = case boxity of
|
||||||
[ docSeq
|
Boxed -> (docLit $ Text.pack "(", docLit $ Text.pack ")")
|
||||||
$ [ docLit $ Text.pack "(" ]
|
Unboxed -> (docLit $ Text.pack "(#", docLit $ Text.pack "#)")
|
||||||
++ List.intersperse (appSep $ docLit $ Text.pack ",") argDocs
|
case splitFirstLast argDocs of
|
||||||
++ [ docLit $ Text.pack ")"]
|
FirstLastEmpty -> docSeq
|
||||||
-- TODO
|
[ openLit
|
||||||
|
, docNodeAnnKW lexpr (Just AnnOpenP) $ closeLit
|
||||||
]
|
]
|
||||||
Unboxed -> docAlt
|
FirstLastSingleton e -> docAlt
|
||||||
|
[ docCols ColTuple
|
||||||
|
[ openLit
|
||||||
|
, docNodeAnnKW lexpr (Just AnnOpenP) $ docForceSingleline e
|
||||||
|
, closeLit
|
||||||
|
]
|
||||||
|
, docSetBaseY $ docLines
|
||||||
[ docSeq
|
[ docSeq
|
||||||
$ [ docLit $ Text.pack "(#" ]
|
[ openLit
|
||||||
++ List.intersperse (appSep $ docLit $ Text.pack ",") argDocs
|
, docNodeAnnKW lexpr (Just AnnOpenP) $ docForceSingleline e
|
||||||
++ [ docLit $ Text.pack "#)"]
|
]
|
||||||
-- TODO
|
, closeLit
|
||||||
|
]
|
||||||
|
]
|
||||||
|
FirstLast e1 ems eN ->
|
||||||
|
docAltFilter
|
||||||
|
[ (,) (not hasComments)
|
||||||
|
$ docCols ColTuple
|
||||||
|
( [docSeq [openLit, docForceSingleline e1]]
|
||||||
|
++ (ems <&> \e -> docSeq [docCommaSep, docForceSingleline e])
|
||||||
|
++ [docSeq [docCommaSep, docNodeAnnKW lexpr (Just AnnOpenP) (docForceSingleline eN), closeLit]]
|
||||||
|
)
|
||||||
|
, (,) True
|
||||||
|
$ let
|
||||||
|
start = docCols ColTuples
|
||||||
|
[appSep $ openLit, e1]
|
||||||
|
linesM = ems <&> \d ->
|
||||||
|
docCols ColTuples [docCommaSep, d]
|
||||||
|
lineN = docCols ColTuples [docCommaSep, docNodeAnnKW lexpr (Just AnnOpenP) eN]
|
||||||
|
end = closeLit
|
||||||
|
in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN] ++ [end]
|
||||||
]
|
]
|
||||||
ExplicitTuple{} ->
|
ExplicitTuple{} ->
|
||||||
unknownNodeError "ExplicitTuple|.." lexpr
|
unknownNodeError "ExplicitTuple|.." lexpr
|
||||||
|
|
|
@ -168,6 +168,8 @@ data ColSig
|
||||||
| ColListComp
|
| ColListComp
|
||||||
| ColList
|
| ColList
|
||||||
| ColApp
|
| ColApp
|
||||||
|
| ColTuple
|
||||||
|
| ColTuples
|
||||||
| ColOpPrefix -- merge with ColList ? other stuff?
|
| ColOpPrefix -- merge with ColList ? other stuff?
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
|
|
Loading…
Reference in New Issue