Implement hacky workaround for issue 89

pull/141/head
Lennart Spitzner 2018-04-25 19:54:35 +02:00
parent a237e591b2
commit e9aacb27ff
2 changed files with 19 additions and 0 deletions

View File

@ -606,3 +606,8 @@ go l ((IRType, _a) : eqr) = go l eqr
go l ((_, IRType) : eqr) = go l eqr
go _ ((IRTypeError ps t1 t2, _) : _) = Left $ makeError ps t1 t2
go _ ((_, IRTypeError ps t1 t2) : _) = Left $ makeError ps t1 t2
#test issue 89 - type-family-instance
type instance (XPure StageParse) = ()
type Pair a = (a, a)

View File

@ -514,6 +514,20 @@ ppDecl d@(L loc decl) = case decl of
Left ns -> docLines $ return <$> ns
Right n -> return n
layoutBriDoc briDoc
InstD (TyFamInstD{}) -> do
-- this is a (temporary (..)) workaround for "type instance" decls
-- that do not round-trip through exactprint properly.
let fixer s = case List.stripPrefix "type " s of
Just rest | not ("instance" `isPrefixOf` rest) ->
"type instance " ++ rest
_ -> s
str <- mAsk <&> \anns ->
intercalate "\n" $ fmap fixer $ lines' $ ExactPrint.exactPrint d anns
bd <- briDocMToPPM $ allocateNode $ BDFExternal (ExactPrint.mkAnnKey d)
(foldedAnnKeys d)
False
(Text.pack str)
layoutBriDoc bd
_ -> briDocMToPPM (briDocByExactNoComment d) >>= layoutBriDoc
-- Prints the information associated with the module annotation