elm-ast
elm-ast copied to clipboard
Stricter type (alias) for module parser?
The parser result is a list of statements at the moment. Are there any plans to add a stricter/richer type or type alias to only support valid combinations of statements, like only one module declaration at the top of the file? This is partially related to the question in https://github.com/Bogdanp/elm-ast/pull/7. Or should something like this be done in some elm-ast-extra package?
I think this is a good idea and that it would make sense for something like that to exist in this package. The types of parseModule and parse could then become:
parseModule : OpTable -> String -> (Result (List String) Module, Context)
parse: String -> (Result (List String) Module, Context)
which would make them more useful for someone wanting to parse valid Elm source and for anyone wanting to do more generic stuff parse{Expression,Statement,OpTable} would likely be enough since they can be used to produce List {Expression,Statement} and OpTable respectively.
Cool, I'm going to sketch out some types in the next couple of days...