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

Fix parser on identifiers which aren't type applications but use references #208

Open
andrevidela opened this issue Feb 29, 2020 · 1 comment

Comments

@andrevidela
Copy link
Collaborator

andrevidela commented Feb 29, 2020

(specialised Int)
(specialised String)
(specialised Date)

(name Amount (mu (MkAmount Int)))
(name Hash (mu (MkHash String)))
(name Transaction (* Hash Date Amount))

this fails on Hash at the last line because Hash is parsed as "(1 ** (Hash := (mu [MkHash: {1}])))" which the parser understands as a 1-argument type constructor.

The index points to the reference in context, in the case "String" (looks like the indices are 1 lower than they should but that shouldn't affect parsing). Since Hash Date and Amount are placed one after the other, it looks like we're giving Hash 2 arguments instead of 1. While in truth Hash doesn't take any arguments since it points to a reference in context.

Possible solutions:

  • do nothing and deprecate when the new parser Index free syntax #204 is merged
  • parse everything as a (n ** Def (x + n)) where x is the size of the references in context and do some arithmetic in order to check if an identifier needs to be applied to arguments. That means that (name Amount (mu (MkAmount Int))) parses as (3 ** (Amount := (mu [MkAmount: {0}]))
@andrevidela
Copy link
Collaborator Author

So maybe this can be solved using the new SpecialList Type. Where specialisations are mapping to types with other kinds than just *

So in that case Hash could not possibly be parsed as an application since it has kind *.

Maybe we need to change the format to account for this and have specialised types always declare their arities:

(specialised Int 0)
(specialised List 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant