Fix/Implement empty type constraint handling (fixes #133)

pull/132/head
Lennart Spitzner 2018-04-02 17:11:53 +02:00
parent b219a23684
commit b43ee43220
2 changed files with 16 additions and 4 deletions

View File

@ -587,3 +587,15 @@ alternatives = -- a
<|> alterantiveTwo -- d
<|> alternativeThree -- e
) -- f
#test issue 133
{-# LANGUAGE ScopedTypeVariables #-}
func
:: forall a
. ()
=> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
func
:: ()
=> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -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