topLevelDeclP :: Parser [SrcAnnTopLevelDecl]
topLevelDeclP = typ <|> var <|> fun
    where
        typ = fmap (map fromDeclStmt) typeDeclP
        var = fmap (map fromDeclStmt) varDeclP
        fun = fmap (:[]) (fmap TopLevelFun funDecl)

-- | Converts a declaration statement into a top-level declaration. This is
-- so we can just use the same parser twice.
topLevelDeclP :: Parser [SrcAnnTopLevelDecl]
topLevelDeclP = typ <|> var <|> fun
    where
        typ = fmap (map fromDeclStmt) typeDeclP
        var = fmap (map fromDeclStmt) varDeclP
        fun = fmap (:[]) (fmap TopLevelFun funDecl)

-- | Converts a declaration statement into a top-level declaration. This is
-- so we can just use the same parser twice.
topLevelDeclP = typ <|> var <|> fun
    where
        typ = fmap (map fromDeclStmt) typeDeclP
        var = fmap (map fromDeclStmt) varDeclP
        fun = fmap (:[]) (fmap TopLevelFun funDecl)

-- | Converts a declaration statement into a top-level declaration. This is
-- so we can just use the same parser twice.