Maybe AList
confuses representation and limits precise reprinting
#231
Labels
Maybe AList
confuses representation and limits precise reprinting
#231
The Fortran AST makes heavy use of the
AList
type to attach metadata to a list as well as each of its elements. However, it often gets used asMaybe AList
to provide an easy out for the empty case (where you could just as well use an empty list inside theAList
). This has a few effects:Nothing
rather than adding all theAList
metadataNothing
andJust []
now existNothing
case doesn't store aSrcSpan
Maybe
(results in lots offromMaybe []
)ALists are essentially a common piece of AST factored out - in particular, they don't map to any one piece of syntax. It would be possible to refactor
AList
s (or rather, add a bunch more) so that they store all their relevant syntactic information. e.g. some start with,
, some may not be bracketed when empty. That way, the type tells us more, and the pretty printing and reprinting typeclass instances can be simplified.A sketch would be:
where
ext
would be instantiated as aBool
-like (e.g.data Brackets = Brackets | OmitBrackets
) or something else.The text was updated successfully, but these errors were encountered: