{-# language DeriveFunctor, DeriveFoldable, DeriveTraversable, DeriveGeneric #-}
module Language.Python.Syntax.Module
( Module (ModuleEmpty, ModuleBlankFinal, ModuleBlank, ModuleStatement)
)
where
import GHC.Generics (Generic)
import Language.Python.Syntax.Expr
import Language.Python.Syntax.Statement
import Language.Python.Syntax.Whitespace
data Module v a
= ModuleEmpty
| ModuleBlankFinal (Blank a)
| ModuleBlank (Blank a) Newline (Module v a)
| ModuleStatement (Statement v a) (Module v a)
deriving (Eq, Show, Functor, Foldable, Traversable, Generic)
instance HasStatements Module where
_Statements f = go
where
go ModuleEmpty = pure ModuleEmpty
go (ModuleBlankFinal a) = pure $ ModuleBlankFinal a
go (ModuleBlank a b c) = ModuleBlank a b <$> go c
go (ModuleStatement a b) = ModuleStatement <$> f a <*> go b
instance HasExprs Module where
_Exprs = _Statements._Exprs