{-# LANGUAGE CPP #-}
{-# LANGUAGE RecordWildCards #-}
module HIndent.Ast.Declaration.Data
( DataDeclaration
, mkDataDeclaration
) where
import HIndent.Ast.Declaration.Data.Body
import HIndent.Ast.Declaration.Data.Header
import HIndent.Ast.NodeComments
import qualified HIndent.GhcLibParserWrapper.GHC.Hs as GHC
import {-# SOURCE #-} HIndent.Pretty
import HIndent.Pretty.NodeComments
data DataDeclaration = DataDeclaration
{ :: Header
, DataDeclaration -> DataBody
body :: DataBody
}
instance CommentExtraction DataDeclaration where
nodeComments :: DataDeclaration -> NodeComments
nodeComments DataDeclaration {} = [LEpaComment] -> [LEpaComment] -> [LEpaComment] -> NodeComments
NodeComments [] [] []
instance Pretty DataDeclaration where
pretty' :: DataDeclaration -> Printer ()
pretty' DataDeclaration {DataBody
Header
header :: DataDeclaration -> Header
body :: DataDeclaration -> DataBody
header :: Header
body :: DataBody
..} = Header -> Printer ()
forall a. Pretty a => a -> Printer ()
pretty Header
header Printer () -> Printer () -> Printer ()
forall a b. Printer a -> Printer b -> Printer b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> DataBody -> Printer ()
forall a. Pretty a => a -> Printer ()
pretty DataBody
body
mkDataDeclaration :: GHC.TyClDecl GHC.GhcPs -> Maybe DataDeclaration
mkDataDeclaration :: TyClDecl GhcPs -> Maybe DataDeclaration
mkDataDeclaration decl :: TyClDecl GhcPs
decl@GHC.DataDecl {XDataDecl GhcPs
LIdP GhcPs
LexicalFixity
LHsQTyVars GhcPs
HsDataDefn GhcPs
tcdDExt :: XDataDecl GhcPs
tcdLName :: LIdP GhcPs
tcdTyVars :: LHsQTyVars GhcPs
tcdFixity :: LexicalFixity
tcdDataDefn :: HsDataDefn GhcPs
tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDExt :: forall pass. TyClDecl pass -> XDataDecl pass
..} =
Header -> DataBody -> DataDeclaration
DataDeclaration (Header -> DataBody -> DataDeclaration)
-> Maybe Header -> Maybe (DataBody -> DataDeclaration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TyClDecl GhcPs -> Maybe Header
mkHeader TyClDecl GhcPs
decl Maybe (DataBody -> DataDeclaration)
-> Maybe DataBody -> Maybe DataDeclaration
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DataBody -> Maybe DataBody
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (HsDataDefn GhcPs -> DataBody
mkDataBody HsDataDefn GhcPs
tcdDataDefn)
mkDataDeclaration TyClDecl GhcPs
_ = Maybe DataDeclaration
forall a. Maybe a
Nothing