elm-ast icon indicating copy to clipboard operation
elm-ast copied to clipboard

Stricter type (alias) for module parser?

Open klaftertief opened this issue 9 years ago • 2 comments
trafficstars

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?

klaftertief avatar Sep 30 '16 22:09 klaftertief

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.

Bogdanp avatar Oct 01 '16 07:10 Bogdanp

Cool, I'm going to sketch out some types in the next couple of days...

klaftertief avatar Oct 01 '16 20:10 klaftertief