diff --git a/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/DataDecl.hs b/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/DataDecl.hs index 0793648..b961ddb 100644 --- a/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/DataDecl.hs +++ b/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/DataDecl.hs @@ -17,12 +17,13 @@ import Language.Haskell.Brittany.Internal.Components.BriDoc layoutDataDecl :: LTyClDecl GhcPs + -> EpAnn [AddEpAnn] -> LIdP GhcPs -> LHsQTyVars GhcPs -> [LHsTypeArg GhcPs] -> HsDataDefn GhcPs -> ToBriDocM BriDocNumbered -layoutDataDecl ltycl name (HsQTvs _ bndrs) pats defn = case defn of +layoutDataDecl ltycl declEpAnn name (HsQTvs _ bndrs) pats defn = case defn of -- newtype MyType a b = MyType .. HsDataDefn NoExtField NewType Nothing _ctype Nothing [cons] mDerivs -> case cons of @@ -43,7 +44,7 @@ layoutDataDecl ltycl name (HsQTvs _ bndrs) pats defn = case defn of -- , appSep tyVarLine -- ] rhsDoc <- return <$> createDetailsDoc consNameStr details - createDerivingPar mDerivs $ docSeq + docHandleComms declEpAnn $ createDerivingPar mDerivs $ docSeq [ appSep $ docLitS "newtype" , appSep $ docLit nameStr , appSep tyVarLine @@ -66,7 +67,7 @@ layoutDataDecl ltycl name (HsQTvs _ bndrs) pats defn = case defn of nameStr <- lrdrNameToTextAnn name tyVarLine <- return <$> createBndrDoc bndrs patDocs <- mapM shareDoc $ layoutHsTyPats pats - createDerivingPar mDerivs $ docSeq + docHandleComms declEpAnn $ createDerivingPar mDerivs $ docSeq [ appSep $ docLitS "data" , lhsContextDoc , appSep $ docLit nameStr @@ -122,7 +123,7 @@ layoutDataDecl ltycl name (HsQTvs _ bndrs) pats defn = case defn of ] (Nothing, Nothing) -> docSeq [docLitS "=", docSeparator, rhsDoc] - createDerivingPar mDerivs $ docAlt + docHandleComms declEpAnn $ createDerivingPar mDerivs $ docAlt [ -- data D = forall a . Show a => D a docSeq [ -- TOOD92 docNodeAnnKW ltycl (Just GHC.AnnData) $ diff --git a/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Decl.hs b/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Decl.hs index b461a01..0d11d2d 100644 --- a/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Decl.hs +++ b/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Decl.hs @@ -787,7 +787,7 @@ layoutTyCl ltycl@(L _loc tycl) = case tycl of 1 typeDoc DataDecl epAnn name tyVars _ dataDefn -> - docHandleComms epAnn $ layoutDataDecl ltycl name tyVars [] dataDefn + layoutDataDecl ltycl epAnn name tyVars [] dataDefn _ -> briDocByExactNoComment ltycl layoutTyVarBndr :: Bool -> ToBriDoc (HsTyVarBndr ()) @@ -945,8 +945,9 @@ layoutClsInst (L declLoc _) cid = do layoutDataFamInstDecl ldfid@(L _ (DataFamInstDecl famEqn)) = docHandleComms ldfid $ case famEqn of FamEqn epAnn tycon bndrs pats Prefix rhs -> do - docHandleComms epAnn $ layoutDataDecl + layoutDataDecl (error "Unsupported form of DataFamInstDecl") + epAnn tycon (case bndrs of HsOuterImplicit NoExtField -> HsQTvs NoExtField []