From b43ee432202281c66ae8a5c0e0fcb1edb0acf1f1 Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Mon, 2 Apr 2018 17:11:53 +0200 Subject: [PATCH] Fix/Implement empty type constraint handling (fixes #133) --- src-literatetests/15-regressions.blt | 12 ++++++++++++ .../Haskell/Brittany/Internal/Layouters/Type.hs | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src-literatetests/15-regressions.blt b/src-literatetests/15-regressions.blt index d84ec79..d59b844 100644 --- a/src-literatetests/15-regressions.blt +++ b/src-literatetests/15-regressions.blt @@ -587,3 +587,15 @@ alternatives = -- a <|> alterantiveTwo -- d <|> alternativeThree -- e ) -- f + +#test issue 133 +{-# LANGUAGE ScopedTypeVariables #-} +func + :: forall a + . () + => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + -> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +func + :: () + => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + -> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs b/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs index 11e0eed..646f986 100644 --- a/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs +++ b/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs @@ -47,7 +47,7 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of t <- lrdrNameToTextAnn name docWrapNode name $ docLit t #endif - HsForAllTy bndrs (L _ (HsQualTy (L _ cntxts@(_:_)) typ2)) -> do + HsForAllTy bndrs (L _ (HsQualTy (L _ cntxts) typ2)) -> do typeDoc <- docSharedWrapper layoutType typ2 tyVarDocs <- bndrs `forM` \case (L _ (UserTyVar name)) -> return $ (lrdrNameToText name, Nothing) @@ -90,6 +90,7 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of ]) ] contextDoc = case cntxtDocs of + [] -> docLit $ Text.pack "()" [x] -> x _ -> docAlt [ let @@ -210,13 +211,12 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of ] ) ] - (HsQualTy (L _ []) _) -> - briDocByExactInlineOnly "HsQualTy [] _" ltype - HsQualTy lcntxts@(L _ cntxts@(_:_)) typ1 -> do + HsQualTy lcntxts@(L _ cntxts) typ1 -> do typeDoc <- docSharedWrapper layoutType typ1 cntxtDocs <- cntxts `forM` docSharedWrapper layoutType let contextDoc = docWrapNode lcntxts $ case cntxtDocs of + [] -> docLit $ Text.pack "()" [x] -> x _ -> docAlt [ let