Fix parentheses around kind signatures, fixes #64
parent
f86665a251
commit
b1c6be7acd
|
@ -477,3 +477,12 @@ test :: Proxy '[ 'True]
|
||||||
#pending fix does not work on 8.0.2
|
#pending fix does not work on 8.0.2
|
||||||
test :: Proxy '[Bool]
|
test :: Proxy '[Bool]
|
||||||
|
|
||||||
|
#test issue 64
|
||||||
|
{-# LANGUAGE RankNTypes, KindSignatures #-}
|
||||||
|
func
|
||||||
|
:: forall m str
|
||||||
|
. (Str str, Monad m)
|
||||||
|
=> Int
|
||||||
|
-> Proxy (str :: [*])
|
||||||
|
-> m (Tagged str String)
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ module Language.Haskell.Brittany.Internal.LayouterBasics
|
||||||
, allocateNode
|
, allocateNode
|
||||||
, docSharedWrapper
|
, docSharedWrapper
|
||||||
, hasAnyCommentsBelow
|
, hasAnyCommentsBelow
|
||||||
|
, hasAnnKeyword
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -239,6 +240,19 @@ hasAnyCommentsBelow ast@(L l _) = do
|
||||||
$ Map.elems
|
$ Map.elems
|
||||||
$ anns
|
$ anns
|
||||||
|
|
||||||
|
hasAnnKeyword
|
||||||
|
:: (Data a, MonadMultiReader (Map AnnKey Annotation) m)
|
||||||
|
=> Located a
|
||||||
|
-> AnnKeywordId
|
||||||
|
-> m Bool
|
||||||
|
hasAnnKeyword ast annKeyword = do
|
||||||
|
anns <- mAsk
|
||||||
|
let hasK (ExactPrint.Types.G x, _) = x == annKeyword
|
||||||
|
hasK _ = False
|
||||||
|
pure $ case Map.lookup (ExactPrint.Types.mkAnnKey ast) anns of
|
||||||
|
Nothing -> False
|
||||||
|
Just (ExactPrint.Types.Ann _ _ _ aks _ _) -> any hasK aks
|
||||||
|
|
||||||
-- new BriDoc stuff
|
-- new BriDoc stuff
|
||||||
|
|
||||||
allocateNode
|
allocateNode
|
||||||
|
|
|
@ -14,7 +14,11 @@ import Language.Haskell.Brittany.Internal.Types
|
||||||
import Language.Haskell.Brittany.Internal.LayouterBasics
|
import Language.Haskell.Brittany.Internal.LayouterBasics
|
||||||
|
|
||||||
import RdrName ( RdrName(..) )
|
import RdrName ( RdrName(..) )
|
||||||
import GHC ( runGhc, GenLocated(L), moduleNameString )
|
import GHC ( runGhc
|
||||||
|
, GenLocated(L)
|
||||||
|
, moduleNameString
|
||||||
|
, AnnKeywordId (..)
|
||||||
|
)
|
||||||
import Language.Haskell.GHC.ExactPrint.Types ( mkAnnKey )
|
import Language.Haskell.GHC.ExactPrint.Types ( mkAnnKey )
|
||||||
import HsSyn
|
import HsSyn
|
||||||
import Name
|
import Name
|
||||||
|
@ -521,19 +525,47 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of
|
||||||
HsKindSig typ1 kind1 -> do
|
HsKindSig typ1 kind1 -> do
|
||||||
typeDoc1 <- docSharedWrapper layoutType typ1
|
typeDoc1 <- docSharedWrapper layoutType typ1
|
||||||
kindDoc1 <- docSharedWrapper layoutType kind1
|
kindDoc1 <- docSharedWrapper layoutType kind1
|
||||||
|
hasParens <- hasAnnKeyword ltype AnnOpenP
|
||||||
docAlt
|
docAlt
|
||||||
[ docSeq
|
[ if hasParens
|
||||||
[ docForceSingleline typeDoc1
|
then docSeq
|
||||||
, docLit $ Text.pack " :: "
|
[ docLit $ Text.pack "("
|
||||||
, docForceSingleline kindDoc1
|
, docForceSingleline typeDoc1
|
||||||
]
|
, docSeparator
|
||||||
, docPar
|
, docLit $ Text.pack "::"
|
||||||
|
, docSeparator
|
||||||
|
, docForceSingleline kindDoc1
|
||||||
|
, docLit $ Text.pack ")"
|
||||||
|
]
|
||||||
|
else docSeq
|
||||||
|
[ docForceSingleline typeDoc1
|
||||||
|
, docSeparator
|
||||||
|
, docLit $ Text.pack "::"
|
||||||
|
, docSeparator
|
||||||
|
, docForceSingleline kindDoc1
|
||||||
|
]
|
||||||
|
, if hasParens
|
||||||
|
then docLines
|
||||||
|
[ docCols
|
||||||
|
ColTyOpPrefix
|
||||||
|
[ docWrapNodeRest ltype $ docParenLSep
|
||||||
|
, docAddBaseY (BrIndentSpecial 3) $ typeDoc1
|
||||||
|
]
|
||||||
|
, docCols
|
||||||
|
ColTyOpPrefix
|
||||||
|
[ docWrapNodeRest ltype $ docLit $ Text.pack ":: "
|
||||||
|
, docAddBaseY (BrIndentSpecial 3) kindDoc1
|
||||||
|
]
|
||||||
|
, (docLit $ Text.pack ")")
|
||||||
|
]
|
||||||
|
else docPar
|
||||||
typeDoc1
|
typeDoc1
|
||||||
( docCols ColTyOpPrefix
|
( docCols
|
||||||
[ docWrapNodeRest ltype
|
ColTyOpPrefix
|
||||||
$ docLit $ Text.pack ":: "
|
[ docWrapNodeRest ltype $ docLit $ Text.pack ":: "
|
||||||
, docAddBaseY (BrIndentSpecial 3) kindDoc1
|
, docAddBaseY (BrIndentSpecial 3) kindDoc1
|
||||||
])
|
]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
HsBangTy{} -> -- TODO
|
HsBangTy{} -> -- TODO
|
||||||
briDocByExactInlineOnly "HsBangTy{}" ltype
|
briDocByExactInlineOnly "HsBangTy{}" ltype
|
||||||
|
|
Loading…
Reference in New Issue