Merge pull request #105 from eborden/datadecl
Make record declarations respect alignmentremotes/eborden/origin/datadecl
commit
a0aaffaae6
|
@ -295,6 +295,47 @@ func = f
|
||||||
f = id
|
f = id
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
#group data type declarations
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
#test single record
|
||||||
|
data Foo = Bar { foo :: Baz }
|
||||||
|
|
||||||
|
#test record multiple names
|
||||||
|
data Foo = Bar { foo, bar :: Baz }
|
||||||
|
|
||||||
|
#test record multiple types
|
||||||
|
data Foo = Bar
|
||||||
|
{ foo :: Baz
|
||||||
|
, bars :: Bizzz
|
||||||
|
}
|
||||||
|
|
||||||
|
#test record multiple types and names
|
||||||
|
data Foo = Bar
|
||||||
|
{ foo, biz :: Baz
|
||||||
|
, bar :: Bizzz
|
||||||
|
}
|
||||||
|
|
||||||
|
#test record multiple types deriving
|
||||||
|
data Foo = Bar
|
||||||
|
{ fooz :: Baz
|
||||||
|
, bar :: Bizzz
|
||||||
|
}
|
||||||
|
deriving Show
|
||||||
|
|
||||||
|
#test record multiple types deriving
|
||||||
|
data Foo = Bar
|
||||||
|
{ foo :: Baz
|
||||||
|
, bars :: Bizzz
|
||||||
|
}
|
||||||
|
deriving (Show, Eq, Monad, Functor, Traversable, Foldable)
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -434,6 +434,7 @@ alignColsLines bridocs = do -- colInfos `forM_` \colInfo -> do
|
||||||
(BDCols ColBindStmt _) -> True
|
(BDCols ColBindStmt _) -> True
|
||||||
(BDCols ColDoLet _) -> True
|
(BDCols ColDoLet _) -> True
|
||||||
(BDCols ColRecUpdate _) -> False
|
(BDCols ColRecUpdate _) -> False
|
||||||
|
(BDCols ColRecDecl _) -> False
|
||||||
(BDCols ColListComp _) -> False
|
(BDCols ColListComp _) -> False
|
||||||
(BDCols ColList _) -> False
|
(BDCols ColList _) -> False
|
||||||
(BDCols ColApp _) -> True
|
(BDCols ColApp _) -> True
|
||||||
|
|
|
@ -173,7 +173,7 @@ createDetailsDoc consNameStr details = case details of
|
||||||
[ docLit consNameStr
|
[ docLit consNameStr
|
||||||
, docSeparator
|
, docSeparator
|
||||||
, appSep $ docLit $ Text.pack "{"
|
, appSep $ docLit $ Text.pack "{"
|
||||||
, createNamesAndTypeDoc names t
|
, docSeq $ createNamesAndTypeDoc names t
|
||||||
, docSeparator
|
, docSeparator
|
||||||
, docLit $ Text.pack "}"
|
, docLit $ Text.pack "}"
|
||||||
]
|
]
|
||||||
|
@ -181,14 +181,13 @@ createDetailsDoc consNameStr details = case details of
|
||||||
docAddBaseY BrIndentRegular $ docPar
|
docAddBaseY BrIndentRegular $ docPar
|
||||||
(docLit consNameStr)
|
(docLit consNameStr)
|
||||||
(docLines
|
(docLines
|
||||||
[ docSeq
|
[ docCols ColRecDecl
|
||||||
[ docLit $ Text.pack "{ "
|
$ docLit (Text.pack "{ ")
|
||||||
, let L _ (ConDeclField names t _) = fstField
|
: let L _ (ConDeclField names t _) = fstField
|
||||||
in createNamesAndTypeDoc names t
|
in createNamesAndTypeDoc names t
|
||||||
]
|
|
||||||
, docLines
|
, docLines
|
||||||
$ (\(L _ (ConDeclField names t _)) ->
|
$ (\(L _ (ConDeclField names t _)) ->
|
||||||
docSeq [docCommaSep, createNamesAndTypeDoc names t])
|
docCols ColRecDecl $ docCommaSep : createNamesAndTypeDoc names t)
|
||||||
<$> fields
|
<$> fields
|
||||||
, docLit $ Text.pack "}"
|
, docLit $ Text.pack "}"
|
||||||
]
|
]
|
||||||
|
@ -213,15 +212,19 @@ createForallDoc (Just (HsQTvs _ bs _)) = do
|
||||||
]
|
]
|
||||||
|
|
||||||
createNamesAndTypeDoc
|
createNamesAndTypeDoc
|
||||||
:: [GenLocated t (FieldOcc u)] -> Located (HsType RdrName) -> ToBriDocM BriDocNumbered
|
:: [GenLocated t (FieldOcc u)] -> Located (HsType RdrName) -> [ToBriDocM BriDocNumbered]
|
||||||
createNamesAndTypeDoc names t = docSeq
|
createNamesAndTypeDoc names t =
|
||||||
[ docSeq
|
[ docSeq
|
||||||
$ List.intersperse docCommaSep
|
[ docSeq
|
||||||
$ names
|
$ List.intersperse docCommaSep
|
||||||
<&> \(L _ (FieldOcc fieldName _)) ->
|
$ names
|
||||||
docLit =<< lrdrNameToTextAnn fieldName
|
<&> \(L _ (FieldOcc fieldName _)) ->
|
||||||
, docSeparator
|
docLit =<< lrdrNameToTextAnn fieldName
|
||||||
, docLit $ Text.pack "::"
|
, docSeparator
|
||||||
, docSeparator
|
]
|
||||||
, layoutType t
|
, docSeq
|
||||||
|
[ docLit $ Text.pack "::"
|
||||||
|
, docSeparator
|
||||||
|
, layoutType t
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
|
@ -172,6 +172,7 @@ data ColSig
|
||||||
| ColBindStmt
|
| ColBindStmt
|
||||||
| ColDoLet -- the non-indented variant
|
| ColDoLet -- the non-indented variant
|
||||||
| ColRecUpdate -- used for both RecCon and RecUpd. TODO: refactor to reflect?
|
| ColRecUpdate -- used for both RecCon and RecUpd. TODO: refactor to reflect?
|
||||||
|
| ColRecDecl
|
||||||
| ColListComp
|
| ColListComp
|
||||||
| ColList
|
| ColList
|
||||||
| ColApp
|
| ColApp
|
||||||
|
|
Loading…
Reference in New Issue