{-# language DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
module Language.Python.Syntax.Module
( Module (ModuleEmpty, ModuleBlankFinal, ModuleBlank, ModuleStatement)
)
where
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)
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