Compare commits
No commits in common. "29000c990c82a8b4b904c05919f7e7ed96f27918" and "084125eed3d366af78fa5d02330bea902fc732e5" have entirely different histories.
29000c990c
...
084125eed3
|
@ -1,74 +0,0 @@
|
||||||
#group extensions/datakinds-promoted-types
|
|
||||||
|
|
||||||
### The spaces before commas are undesirable
|
|
||||||
#test 1
|
|
||||||
test :: Proxy '[ 'True ]
|
|
||||||
test = Proxy @'[ 'True ]
|
|
||||||
#test 2
|
|
||||||
test :: Proxy '[True]
|
|
||||||
test = Proxy @'[True]
|
|
||||||
#test 3
|
|
||||||
test :: Proxy '[ 'True , False ]
|
|
||||||
test = Proxy @'[ 'True , False ]
|
|
||||||
#test 4
|
|
||||||
test :: Proxy '[True , False]
|
|
||||||
test = Proxy @'[True , False]
|
|
||||||
#test 5
|
|
||||||
test :: Proxy '[True , 'False]
|
|
||||||
test = Proxy @'[True , 'False]
|
|
||||||
#test 6
|
|
||||||
test :: Proxy '[ 'True , 'False ]
|
|
||||||
test = Proxy @'[ 'True , 'False ]
|
|
||||||
#test 7
|
|
||||||
test :: Proxy '[ 'Just 'True , False ]
|
|
||||||
test = Proxy @'[ 'Just 'True , False ]
|
|
||||||
#test 8
|
|
||||||
test :: Proxy '[Just True , False]
|
|
||||||
test = Proxy @'[Just True , False]
|
|
||||||
#test 9
|
|
||||||
test :: Proxy '[('True)]
|
|
||||||
test = Proxy @'[('True)]
|
|
||||||
#test 10
|
|
||||||
test :: Proxy ('Just 'True)
|
|
||||||
test = Proxy @('Just 'True)
|
|
||||||
#test 11
|
|
||||||
test :: Proxy ('True)
|
|
||||||
test = Proxy @('True)
|
|
||||||
|
|
||||||
#test with-comment-1
|
|
||||||
test
|
|
||||||
:: Proxy '[-- comment
|
|
||||||
'True ]
|
|
||||||
test = Proxy @'[-- comment
|
|
||||||
'True ]
|
|
||||||
|
|
||||||
#test with-comment-2
|
|
||||||
test
|
|
||||||
:: Proxy '[-- comment
|
|
||||||
True]
|
|
||||||
test = Proxy @'[-- comment
|
|
||||||
True]
|
|
||||||
|
|
||||||
#test with-comment-3
|
|
||||||
test
|
|
||||||
:: Proxy '[{- comment -} 'True ]
|
|
||||||
test = Proxy @'[{- comment -} 'True ]
|
|
||||||
|
|
||||||
#test with-comment-4
|
|
||||||
test
|
|
||||||
:: Proxy '[{- comment -}
|
|
||||||
'True ]
|
|
||||||
test = Proxy @'[{- comment -}
|
|
||||||
'True ]
|
|
||||||
|
|
||||||
#test with-comment-5
|
|
||||||
test
|
|
||||||
:: Proxy '[{- comment -} True]
|
|
||||||
test = Proxy @'[{- comment -} True]
|
|
||||||
|
|
||||||
#test with-comment-6
|
|
||||||
test
|
|
||||||
:: Proxy '[{- comment -}
|
|
||||||
True]
|
|
||||||
test = Proxy @'[{- comment -}
|
|
||||||
True]
|
|
|
@ -503,7 +503,7 @@ v = A { a = 1, b = 2, c = 3 }
|
||||||
test :: Proxy 'Int
|
test :: Proxy 'Int
|
||||||
|
|
||||||
#test issue 63 b
|
#test issue 63 b
|
||||||
test :: Proxy '[ 'True ]
|
test :: Proxy '[ 'True]
|
||||||
|
|
||||||
#test issue 63 c
|
#test issue 63 c
|
||||||
test :: Proxy '[Bool]
|
test :: Proxy '[Bool]
|
||||||
|
|
|
@ -277,22 +277,24 @@ layoutBriDocM = \case
|
||||||
comms <- takeBefore loc
|
comms <- takeBefore loc
|
||||||
printComments comms
|
printComments comms
|
||||||
mModify (\s -> s + CommentCounter (length comms))
|
mModify (\s -> s + CommentCounter (length comms))
|
||||||
mModify $ \s -> s
|
do
|
||||||
{ _lstate_markerForDelta = Nothing
|
state <- mGet
|
||||||
, _lstate_plannedSpace = case _lstate_markerForDelta s of
|
mModify $ \s -> s { _lstate_markerForDelta = Nothing }
|
||||||
Nothing -> _lstate_plannedSpace s
|
case _lstate_markerForDelta state of
|
||||||
Just m ->
|
Just m -> do
|
||||||
let p1 = (srcLocLine m, srcLocCol m)
|
let p1 = (srcLocLine m, srcLocCol m)
|
||||||
p2 = (srcLocLine loc, srcLocCol loc)
|
let p2 = (srcLocLine loc, srcLocCol loc)
|
||||||
-- traceShow (m, ExactPrint.pos2delta p1 p2) $ pure ()
|
let newlinePlanned = case _lstate_plannedSpace state of
|
||||||
in case ExactPrint.pos2delta p1 p2 of
|
PlannedNone -> False
|
||||||
SameLine{} -> _lstate_plannedSpace s
|
PlannedSameline{} -> False
|
||||||
DifferentLine n _ -> case _lstate_plannedSpace s of
|
PlannedNewline{} -> True
|
||||||
PlannedNone -> PlannedNone
|
PlannedDelta{} -> True
|
||||||
PlannedSameline i -> PlannedDelta n (_lstate_curY s + i)
|
-- traceShow (m, ExactPrint.pos2delta p1 p2) $ pure ()
|
||||||
PlannedNewline{} -> PlannedNewline n
|
case ExactPrint.pos2delta p1 p2 of
|
||||||
PlannedDelta{} -> PlannedNewline n
|
SameLine{} -> pure ()
|
||||||
}
|
DifferentLine n _ | newlinePlanned -> layoutWriteNewlines n
|
||||||
|
| otherwise -> pure ()
|
||||||
|
_ -> pure ()
|
||||||
layoutBriDocM bd
|
layoutBriDocM bd
|
||||||
BDFlushCommentsPost loc shouldMark bd -> do
|
BDFlushCommentsPost loc shouldMark bd -> do
|
||||||
layoutBriDocM bd
|
layoutBriDocM bd
|
||||||
|
|
|
@ -158,7 +158,7 @@ layoutType ltype@(L _ typ) = docHandleComms ltype $ case typ of
|
||||||
HsTyVar epAnn promoted name -> docHandleComms epAnn $ do
|
HsTyVar epAnn promoted name -> docHandleComms epAnn $ do
|
||||||
t <- lrdrNameToTextAnnTypeEqualityIsSpecial name
|
t <- lrdrNameToTextAnnTypeEqualityIsSpecial name
|
||||||
case promoted of
|
case promoted of
|
||||||
IsPromoted -> docSeq [docTick, docHandleComms name $ docLit t]
|
IsPromoted -> docSeq [docSeparator, docTick, docHandleComms name $ docLit t]
|
||||||
NotPromoted -> docHandleComms name $ docLit t
|
NotPromoted -> docHandleComms name $ docLit t
|
||||||
HsForAllTy{} -> do
|
HsForAllTy{} -> do
|
||||||
parts <- splitArrowType ltype
|
parts <- splitArrowType ltype
|
||||||
|
@ -429,25 +429,14 @@ layoutType ltype@(L _ typ) = docHandleComms ltype $ case typ of
|
||||||
HsRecTy{} -> -- TODO
|
HsRecTy{} -> -- TODO
|
||||||
briDocByExactInlineOnly "HsRecTy{}" ltype
|
briDocByExactInlineOnly "HsRecTy{}" ltype
|
||||||
HsExplicitListTy epAnn _ typs -> docHandleComms epAnn $ do
|
HsExplicitListTy epAnn _ typs -> docHandleComms epAnn $ do
|
||||||
-- `'['Foo]` isn't valid because it parses as a character. So if the list
|
|
||||||
-- starts with a promoted type var, we swap to `'[ 'Foo ]`.
|
|
||||||
let
|
|
||||||
sepIfHeadPromoted = case typs of
|
|
||||||
(L _ t) : _ | startsWithTick t -> docSeparator
|
|
||||||
_ -> docEmpty
|
|
||||||
|
|
||||||
-- When rendering on multiple lines, this causes commas to line up with the
|
|
||||||
-- opening bracket. Unfortunately it also adds unnecessary space when
|
|
||||||
-- rendering on a single line.
|
|
||||||
let specialCommaSep = appSep $ docLit $ Text.pack " ,"
|
|
||||||
|
|
||||||
typDocs <- typs `forM` (shareDoc . docHandleListElemComms layoutType)
|
typDocs <- typs `forM` (shareDoc . docHandleListElemComms layoutType)
|
||||||
let hasComments = hasAnyCommentsBelow ltype
|
let hasComments = hasAnyCommentsBelow ltype
|
||||||
|
let specialCommaSep = appSep $ docLit $ Text.pack " ,"
|
||||||
docAlt
|
docAlt
|
||||||
[ docSeq
|
[ docSeq
|
||||||
$ [docLit $ Text.pack "'[", sepIfHeadPromoted]
|
$ [docLit $ Text.pack "'["]
|
||||||
++ List.intersperse specialCommaSep (docForceSingleline <$> typDocs)
|
++ List.intersperse specialCommaSep (docForceSingleline <$> typDocs)
|
||||||
++ [sepIfHeadPromoted, docLit $ Text.pack "]"]
|
++ [docLit $ Text.pack "]"]
|
||||||
, case splitFirstLast typDocs of
|
, case splitFirstLast typDocs of
|
||||||
FirstLastEmpty -> docSeq
|
FirstLastEmpty -> docSeq
|
||||||
[ docLit $ Text.pack "'[]" -- TODO92 comments AnnOpenS
|
[ docLit $ Text.pack "'[]" -- TODO92 comments AnnOpenS
|
||||||
|
@ -455,9 +444,7 @@ layoutType ltype@(L _ typ) = docHandleComms ltype $ case typ of
|
||||||
FirstLastSingleton e -> docAlt
|
FirstLastSingleton e -> docAlt
|
||||||
[ docSeq
|
[ docSeq
|
||||||
[ docLit $ Text.pack "'["
|
[ docLit $ Text.pack "'["
|
||||||
, sepIfHeadPromoted
|
|
||||||
, docForceSingleline e -- TODO92 comments AnnOpenS
|
, docForceSingleline e -- TODO92 comments AnnOpenS
|
||||||
, sepIfHeadPromoted
|
|
||||||
, docLit $ Text.pack "]"
|
, docLit $ Text.pack "]"
|
||||||
]
|
]
|
||||||
, docSetBaseY $ docLines
|
, docSetBaseY $ docLines
|
||||||
|
@ -472,7 +459,7 @@ layoutType ltype@(L _ typ) = docHandleComms ltype $ case typ of
|
||||||
FirstLast e1 ems eN -> runFilteredAlternative $ do
|
FirstLast e1 ems eN -> runFilteredAlternative $ do
|
||||||
addAlternativeCond (not hasComments)
|
addAlternativeCond (not hasComments)
|
||||||
$ docSeq
|
$ docSeq
|
||||||
$ [docLit $ Text.pack "'[", sepIfHeadPromoted]
|
$ [docLit $ Text.pack "'["]
|
||||||
++ List.intersperse
|
++ List.intersperse
|
||||||
specialCommaSep
|
specialCommaSep
|
||||||
(docForceSingleline
|
(docForceSingleline
|
||||||
|
@ -554,10 +541,3 @@ withoutSpecificity :: LHsTyVarBndr GHC.Types.Var.Specificity GhcPs -> LHsTyVarBn
|
||||||
withoutSpecificity = fmap $ \case
|
withoutSpecificity = fmap $ \case
|
||||||
UserTyVar a _ c -> UserTyVar a () c
|
UserTyVar a _ c -> UserTyVar a () c
|
||||||
KindedTyVar a _ c d -> KindedTyVar a () c d
|
KindedTyVar a _ c d -> KindedTyVar a () c d
|
||||||
|
|
||||||
-- | Determine if the type starts with a tick mark (single quote) when rendered.
|
|
||||||
startsWithTick :: HsType GhcPs -> Bool
|
|
||||||
startsWithTick = \case
|
|
||||||
HsTyVar _ IsPromoted _ -> True
|
|
||||||
HsAppTy _ (L _ t) _ -> startsWithTick t
|
|
||||||
_ -> False
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import Language.Haskell.Brittany.Internal.Types
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data PlannedSpace
|
data PlanneSpace
|
||||||
= PlannedNone
|
= PlannedNone
|
||||||
| PlannedSameline Int
|
| PlannedSameline Int
|
||||||
| PlannedNewline Int
|
| PlannedNewline Int
|
||||||
|
@ -45,7 +45,7 @@ data LayoutState = LayoutState
|
||||||
-- on the first indented element have an
|
-- on the first indented element have an
|
||||||
-- annotation offset relative to the last
|
-- annotation offset relative to the last
|
||||||
-- non-indented element, which is confusing.
|
-- non-indented element, which is confusing.
|
||||||
, _lstate_plannedSpace :: PlannedSpace
|
, _lstate_plannedSpace :: PlanneSpace
|
||||||
-- , _lstate_isNewline :: NewLineState
|
-- , _lstate_isNewline :: NewLineState
|
||||||
-- -- captures if the layouter currently is in a new line, i.e. if the
|
-- -- captures if the layouter currently is in a new line, i.e. if the
|
||||||
-- -- current line only contains (indentation) spaces.
|
-- -- current line only contains (indentation) spaces.
|
||||||
|
|
Loading…
Reference in New Issue