Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The nonempty macro should result in the Haskell backend using the NonEmpty type? #371

Open
MatthewDaggitt opened this issue Jun 28, 2021 · 2 comments
Labels
AST Concerning the generated abstract syntax Haskell lists Concerning list categories and separator/terminator/delimiter pragmas
Milestone

Comments

@MatthewDaggitt
Copy link

You can write separator nonempty Stmt "," in the grammar but the generated Abs file still uses the type [Stmt] rather than NonEmpty Stmt. This means that you have to duplicate the empty-case check again wherever you use the generated data type.

e.g.

ELitSeq.    Expr ::= "[" [Expr] "]";

separator nonempty Expr "";

results in

data Expr = ELitSeq [Expr]

rather than

data Expr = ELitSeq (NonEmpty Expr)

How hard would this be to fix and where would one start?

@andreasabel
Copy link
Member

I think this would be a nice improvement. This isn't hard to fix, it is more that this will be a backwards-incompatible change. So one has to provide a legacy mode. Or, in this case we could produce code using type List1 which is then a type synonym for either [ ] or Data.List.Nonempty depending on which module one includes.

@andreasabel andreasabel added AST Concerning the generated abstract syntax Haskell lists Concerning list categories and separator/terminator/delimiter pragmas labels Jun 28, 2021
@andreasabel
Copy link
Member

#267, flexible syntax tree production, would also fix the present issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AST Concerning the generated abstract syntax Haskell lists Concerning list categories and separator/terminator/delimiter pragmas
Projects
None yet
Development

No branches or pull requests

2 participants