-- | Parses a package: the package header (`package` keyword followed by an
-- identifier), followed by a list of top-level declarations.
packageP :: Parser SrcAnnPackage
packageP = do
    name <- (kwPackage >>= noSemiP) >> (identifier >>= requireSemiP)
    decls <- many topLevelDeclP


    pure $ Package name (concat decls)

-- | Parses a top-level declaration: either a regular declaration (type/var) or
-- a function declaration. Since declarations can be distributed, this returns
-- a list.
packageP :: Parser SrcAnnPackage
packageP = do
    name <- (kwPackage >>= noSemiP) >> (identifier >>= requireSemiP)
    decls <- many topLevelDeclP


    pure $ Package name (concat decls)

-- | Parses a top-level declaration: either a regular declaration (type/var) or
-- a function declaration. Since declarations can be distributed, this returns
-- a list.
packageP = do
    name <- (kwPackage >>= noSemiP) >> (identifier >>= requireSemiP)
    decls <- many topLevelDeclP


    pure $ Package name (concat decls)

-- | Parses a top-level declaration: either a regular declaration (type/var) or
-- a function declaration. Since declarations can be distributed, this returns
-- a list.