Move tests, minor Refactoring, Add comments
parent
9755db1d05
commit
71efa54954
|
@ -81,3 +81,17 @@ import Test ( type (++)
|
||||||
, pattern Foo
|
, pattern Foo
|
||||||
, pattern (:.)
|
, pattern (:.)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
## UnboxedTuples + MagicHash
|
||||||
|
#test unboxed-tuple and vanilla names
|
||||||
|
{-# LANGUAGE UnboxedTuples #-}
|
||||||
|
spanKey :: (# Int, Int #) -> (# Int, Int #)
|
||||||
|
spanKey = case foo of
|
||||||
|
(# bar, baz #) -> (# baz, bar #)
|
||||||
|
|
||||||
|
#test unboxed-tuple and hashed name
|
||||||
|
{-# LANGUAGE MagicHash, UnboxedTuples #-}
|
||||||
|
spanKey :: (# Int#, Int# #) -> (# Int#, Int# #)
|
||||||
|
spanKey = case foo of
|
||||||
|
(# bar#, baz# #) -> (# baz# +# bar#, bar# #)
|
||||||
|
|
|
@ -650,15 +650,3 @@ jaicyhHumzo btrKpeyiFej mava = do
|
||||||
)
|
)
|
||||||
Xcde{} -> (s, Pioemav)
|
Xcde{} -> (s, Pioemav)
|
||||||
pure imomue
|
pure imomue
|
||||||
|
|
||||||
#test unboxed-tuple and vanilla names
|
|
||||||
{-# LANGUAGE UnboxedTuples #-}
|
|
||||||
spanKey :: (# Int, Int #) -> (# Int, Int #)
|
|
||||||
spanKey = case foo of
|
|
||||||
(# bar, baz #) -> (# baz, bar #)
|
|
||||||
|
|
||||||
#test unboxed-tuple and hashed name
|
|
||||||
{-# LANGUAGE MagicHash, UnboxedTuples #-}
|
|
||||||
spanKey :: (# Int#, Int# #) -> (# Int#, Int# #)
|
|
||||||
spanKey = case foo of
|
|
||||||
(# bar#, baz# #) -> (# baz# +# bar#, bar# #)
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ module Language.Haskell.Brittany.Internal.LayouterBasics
|
||||||
, docParenLSep
|
, docParenLSep
|
||||||
, docParenL
|
, docParenL
|
||||||
, docParenR
|
, docParenR
|
||||||
, docParenHashL
|
, docParenHashLSep
|
||||||
, docParenHashR
|
, docParenHashRSep
|
||||||
, docBracketL
|
, docBracketL
|
||||||
, docBracketR
|
, docBracketR
|
||||||
, docTick
|
, docTick
|
||||||
|
@ -537,17 +537,23 @@ docCommaSep = appSep $ docLit $ Text.pack ","
|
||||||
docParenLSep :: ToBriDocM BriDocNumbered
|
docParenLSep :: ToBriDocM BriDocNumbered
|
||||||
docParenLSep = appSep docParenL
|
docParenLSep = appSep docParenL
|
||||||
|
|
||||||
|
-- TODO: we don't make consistent use of these (yet). However, I think the
|
||||||
|
-- most readable approach overall might be something else: define
|
||||||
|
-- `lit = docLit . Text.pack` and `prepSep = docSeq [docSeparator, x]`.
|
||||||
|
-- I think those two would make the usage most readable.
|
||||||
|
-- lit "(" and appSep (lit "(") are understandable and short without
|
||||||
|
-- introducing a new top-level binding for all types of parentheses.
|
||||||
docParenL :: ToBriDocM BriDocNumbered
|
docParenL :: ToBriDocM BriDocNumbered
|
||||||
docParenL = docLit $ Text.pack "("
|
docParenL = docLit $ Text.pack "("
|
||||||
|
|
||||||
docParenR :: ToBriDocM BriDocNumbered
|
docParenR :: ToBriDocM BriDocNumbered
|
||||||
docParenR = docLit $ Text.pack ")"
|
docParenR = docLit $ Text.pack ")"
|
||||||
|
|
||||||
docParenHashL :: ToBriDocM BriDocNumbered
|
docParenHashLSep :: ToBriDocM BriDocNumbered
|
||||||
docParenHashL = docSeq [docLit $ Text.pack "(#", docSeparator]
|
docParenHashLSep = docSeq [docLit $ Text.pack "(#", docSeparator]
|
||||||
|
|
||||||
docParenHashR :: ToBriDocM BriDocNumbered
|
docParenHashRSep :: ToBriDocM BriDocNumbered
|
||||||
docParenHashR = docSeq [docSeparator, docLit $ Text.pack "#)"]
|
docParenHashRSep = docSeq [docSeparator, docLit $ Text.pack "#)"]
|
||||||
|
|
||||||
docBracketL :: ToBriDocM BriDocNumbered
|
docBracketL :: ToBriDocM BriDocNumbered
|
||||||
docBracketL = docLit $ Text.pack "["
|
docBracketL = docLit $ Text.pack "["
|
||||||
|
|
|
@ -372,7 +372,7 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
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 ")")
|
||||||
Unboxed -> (docParenHashL, docParenHashR)
|
Unboxed -> (docParenHashLSep, docParenHashRSep)
|
||||||
case splitFirstLast argDocs of
|
case splitFirstLast argDocs of
|
||||||
FirstLastEmpty -> docSeq
|
FirstLastEmpty -> docSeq
|
||||||
[ openLit
|
[ openLit
|
||||||
|
|
|
@ -141,7 +141,7 @@ layoutPat lpat@(L _ pat) = docWrapNode lpat $ case pat of
|
||||||
-- (#nestedpat1, nestedpat2, nestedpat3#) -> expr
|
-- (#nestedpat1, nestedpat2, nestedpat3#) -> expr
|
||||||
case boxity of
|
case boxity of
|
||||||
Boxed -> wrapPatListy args "()" docParenL docParenR
|
Boxed -> wrapPatListy args "()" docParenL docParenR
|
||||||
Unboxed -> wrapPatListy args "(##)" docParenHashL docParenHashR
|
Unboxed -> wrapPatListy args "(##)" docParenHashLSep docParenHashRSep
|
||||||
AsPat asName asPat -> do
|
AsPat asName asPat -> do
|
||||||
-- bind@nestedpat -> expr
|
-- bind@nestedpat -> expr
|
||||||
wrapPatPrepend asPat (docLit $ lrdrNameToText asName <> Text.pack "@")
|
wrapPatPrepend asPat (docLit $ lrdrNameToText asName <> Text.pack "@")
|
||||||
|
|
|
@ -392,33 +392,32 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of
|
||||||
unitL = docLit $ Text.pack "()"
|
unitL = docLit $ Text.pack "()"
|
||||||
simpleL = do
|
simpleL = do
|
||||||
docs <- docSharedWrapper layoutType `mapM` typs
|
docs <- docSharedWrapper layoutType `mapM` typs
|
||||||
|
let end = docLit $ Text.pack ")"
|
||||||
|
lines = List.tail docs <&> \d ->
|
||||||
|
docCols ColTyOpPrefix [docCommaSep, d]
|
||||||
docAlt
|
docAlt
|
||||||
[ docSeq $ [docLit $ Text.pack "("]
|
[ docSeq $ [docLit $ Text.pack "("]
|
||||||
++ List.intersperse docCommaSep (docForceSingleline <$> docs)
|
++ List.intersperse docCommaSep (docForceSingleline <$> docs)
|
||||||
++ [docLit $ Text.pack ")"]
|
++ [end]
|
||||||
, let
|
, let line1 = docCols ColTyOpPrefix [docParenLSep, head docs]
|
||||||
start = docCols ColTyOpPrefix [docParenLSep, head docs]
|
|
||||||
lines = List.tail docs <&> \d ->
|
|
||||||
docCols ColTyOpPrefix [docCommaSep, d]
|
|
||||||
end = docLit $ Text.pack ")"
|
|
||||||
in docPar
|
in docPar
|
||||||
(docAddBaseY (BrIndentSpecial 2) $ start)
|
(docAddBaseY (BrIndentSpecial 2) $ line1)
|
||||||
(docLines $ (docAddBaseY (BrIndentSpecial 2) <$> lines) ++ [end])
|
(docLines $ (docAddBaseY (BrIndentSpecial 2) <$> lines) ++ [end])
|
||||||
]
|
]
|
||||||
unboxedL = do
|
unboxedL = do
|
||||||
docs <- docSharedWrapper layoutType `mapM` typs
|
docs <- docSharedWrapper layoutType `mapM` typs
|
||||||
let start = docParenHashL
|
let start = docParenHashLSep
|
||||||
end = docParenHashR
|
end = docParenHashRSep
|
||||||
docAlt
|
docAlt
|
||||||
[ docSeq $ [start]
|
[ docSeq $ [start]
|
||||||
++ List.intersperse docCommaSep docs
|
++ List.intersperse docCommaSep docs
|
||||||
++ [end]
|
++ [end]
|
||||||
, let
|
, let
|
||||||
start' = docCols ColTyOpPrefix [start, head docs]
|
line1 = docCols ColTyOpPrefix [start, head docs]
|
||||||
lines = List.tail docs <&> \d ->
|
lines = List.tail docs <&> \d ->
|
||||||
docCols ColTyOpPrefix [docCommaSep, d]
|
docCols ColTyOpPrefix [docCommaSep, d]
|
||||||
in docPar
|
in docPar
|
||||||
(docAddBaseY (BrIndentSpecial 2) start')
|
(docAddBaseY (BrIndentSpecial 2) line1)
|
||||||
(docLines $ (docAddBaseY (BrIndentSpecial 2) <$> lines) ++ [end])
|
(docLines $ (docAddBaseY (BrIndentSpecial 2) <$> lines) ++ [end])
|
||||||
]
|
]
|
||||||
HsOpTy{} -> -- TODO
|
HsOpTy{} -> -- TODO
|
||||||
|
|
Loading…
Reference in New Issue