From 0742dd7830333a0104778a77e75476bd649ea9f1 Mon Sep 17 00:00:00 2001 From: Taylor Fausak Date: Fri, 29 Oct 2021 00:38:37 +0000 Subject: [PATCH] Fix up layouter type --- .../Brittany/Internal/Layouters/Type.hs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs b/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs index 3437fcd..1ba7e0b 100644 --- a/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs +++ b/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs @@ -30,10 +30,17 @@ import GHC.Hs #else import HsSyn #endif +#if MIN_VERSION_ghc(9,0,0) +import GHC.Types.Name +import GHC.Utils.Outputable ( ftext, showSDocUnsafe ) +import GHC.Types.Basic +import qualified GHC.Types.SrcLoc +#else import Name import Outputable ( ftext, showSDocUnsafe ) import BasicTypes import qualified SrcLoc +#endif import DataTreePrint @@ -56,7 +63,11 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of ] NotPromoted -> docWrapNode name $ docLit t #if MIN_VERSION_ghc(8,10,1) +#if MIN_VERSION_ghc(9,0,0) + HsForAllTy _ tele (L _ (HsQualTy _ (L _ cntxts) typ2)) -> let bndrs = hsf_vis_bndrs tele in do +#else HsForAllTy _ _ bndrs (L _ (HsQualTy _ (L _ cntxts) typ2)) -> do +#endif #else HsForAllTy _ bndrs (L _ (HsQualTy _ (L _ cntxts) typ2)) -> do #endif @@ -146,7 +157,11 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of ) ] #if MIN_VERSION_ghc(8,10,1) +#if MIN_VERSION_ghc(9,0,0) + HsForAllTy _ tele typ2 -> let bndrs = hsf_vis_bndrs tele in do +#else HsForAllTy _ _ bndrs typ2 -> do +#endif #else HsForAllTy _ bndrs typ2 -> do #endif @@ -254,7 +269,11 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of ] ) ] +#if MIN_VERSION_ghc(9,0,0) + HsFunTy _ _ typ1 typ2 -> do +#else HsFunTy _ typ1 typ2 -> do +#endif typeDoc1 <- docSharedWrapper layoutType typ1 typeDoc2 <- docSharedWrapper layoutType typ2 let maybeForceML = case typ2 of @@ -642,11 +661,20 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of #endif layoutTyVarBndrs +#if MIN_VERSION_ghc(9,0,0) + :: [LHsTyVarBndr flag GhcPs] +#else :: [LHsTyVarBndr GhcPs] +#endif -> ToBriDocM [(Text, Maybe (ToBriDocM BriDocNumbered))] layoutTyVarBndrs = mapM $ \case +#if MIN_VERSION_ghc(9,0,0) + (L _ (UserTyVar _ _ name)) -> return $ (lrdrNameToText name, Nothing) + (L _ (KindedTyVar _ _ lrdrName kind)) -> do +#else (L _ (UserTyVar _ name)) -> return $ (lrdrNameToText name, Nothing) (L _ (KindedTyVar _ lrdrName kind)) -> do +#endif d <- docSharedWrapper layoutType kind return $ (lrdrNameToText lrdrName, Just $ d) (L _ (XTyVarBndr{})) -> error "brittany internal error: XTyVarBndr"