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

Value restriction makes it difficult to work with parsing combinators #7

Closed
lambdakris opened this issue Jul 21, 2017 · 1 comment
Closed

Comments

@lambdakris
Copy link

Description

The way the combinators are written, it is tough to work with them since the code doesn't compile due to value restriction errors until a parse function is applied. It might be worthwhile to make the combinators work such that the developer can build them up independently and not have to compose and pass them to a parse function in order to know whether it compiles.

Repro code

let matchOnHome = s "home"
let matchOnPost = s "blog" </> i32

Expected and actual results

I think it would be helpful to be able to write something like the above so that the match expressions can be encapsulated, but right now that code generates value restrictions errors until you apply a parse function.

Related information

  • fable-elmish version: 0.9.2
  • fable-compiler version: 1.1.9
  • fable-core version: 1.1.7
  • Operating system: Windows 10
@et1975
Copy link
Member

et1975 commented Jul 21, 2017

Value restriction is something we have to live with in F#, you can add explicit type annotations to avoid the error. Fundamentally, what makes the parser-combinators attractive and type-safe is their generic nature, creating an API to circumvent that would defeat the purpose.
fable-arch used a port of FParsec, maybe you want to look into that, maybe you'll like that parser better.

@et1975 et1975 closed this as completed Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants