Fix promoted HsTyVars on ghc-8.2.1

This fix does not work on ghc-8.0, because I do not understand
the 8.0 API in this instance. Could be resolved by looking
at annotations, but that really should not be necessary.
pull/75/head
Lennart Spitzner 2017-10-14 23:21:13 +02:00
parent 7d7ec3e8b4
commit f86665a251
3 changed files with 29 additions and 5 deletions

View File

@ -465,3 +465,15 @@ v = A {..} where b = 2
{-# LANGUAGE RecordWildCards #-}
v = A {a = 1, b = 2, c = 3}
#test issue 63 a
#pending fix does not work on 8.0.2
test :: Proxy 'Int
#test issue 63 b
#pending fix does not work on 8.0.2
test :: Proxy '[ 'True]
#test issue 63 c
#pending fix does not work on 8.0.2
test :: Proxy '[Bool]

View File

@ -42,6 +42,7 @@ module Language.Haskell.Brittany.Internal.LayouterBasics
, appSep
, docCommaSep
, docParenLSep
, docTick
, spacifyDocs
, briDocMToPPM
, allocateNode
@ -447,6 +448,9 @@ docCommaSep = appSep $ docLit $ Text.pack ","
docParenLSep :: ToBriDocM BriDocNumbered
docParenLSep = appSep $ docLit $ Text.pack "("
docTick :: ToBriDocM BriDocNumbered
docTick = docLit $ Text.pack "'"
docNodeAnnKW
:: Data.Data.Data ast
=> Located ast

View File

@ -29,12 +29,20 @@ layoutType :: ToBriDoc HsType
layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of
-- _ | traceShow (ExactPrint.Types.mkAnnKey ltype) False -> error "impossible"
#if MIN_VERSION_ghc(8,2,0) /* ghc-8.2 */
HsTyVar _ name -> do
HsTyVar promoted name -> do
t <- lrdrNameToTextAnn name
case promoted of
Promoted -> docSeq
[ docSeparator
, docTick
, docWrapNode name $ docLit t
]
NotPromoted -> docWrapNode name $ docLit t
#else /* ghc-8.0 */
HsTyVar name -> do
#endif
t <- lrdrNameToTextAnn name
docWrapNode name $ docLit t
#endif
HsForAllTy bndrs (L _ (HsQualTy (L _ cntxts@(_:_)) typ2)) -> do
typeDoc <- docSharedWrapper layoutType typ2
tyVarDocs <- bndrs `forM` \case
@ -294,7 +302,7 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of
docAlt
[ docSeq
[ docForceSingleline typeDoc1
, docLit $ Text.pack " "
, docSeparator
, docForceSingleline typeDoc2
]
, docPar
@ -324,7 +332,7 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of
docAlt
[ docSeq
$ docForceSingleline docHead : (docRest >>= \d ->
[ docLit $ Text.pack " ", docForceSingleline d ])
[ docSeparator, docForceSingleline d ])
, docPar docHead (docLines $ docEnsureIndent BrIndentRegular <$> docRest)
]
HsAppsTy (typHead:typRest) -> do
@ -333,7 +341,7 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of
docAlt
[ docSeq
$ docForceSingleline docHead : (docRest >>= \d ->
[ docLit $ Text.pack " ", docForceSingleline d ])
[ docSeparator, docForceSingleline d ])
, docPar docHead (docLines $ docEnsureIndent BrIndentRegular <$> docRest)
]
where