Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upType ascription precedence inconsistency #28
Comments
This comment has been minimized.
This comment has been minimized.
|
Yes, I agree that Dhall's parser should be encodable as an LALR grammar. This is actually how I originally wrote Dhall before I switched to using For the inconsistent treatment of type annotation under lambda abstraction, the correct behavior should be that the type annotation binds tighter than the lambda abstraction, meaning that this: \(x : Natural) -> x : Natural... should be equivalent to this: \(x : Natural) -> (x : Natural)Like you mentioned, this would then make them consistent with Haskell, where the type annotation also binds tighter than lambda abstraction: >>> :type (\x -> x :: Int)
(\x -> x :: Int) :: Int -> IntI'll make the required change soon to this repository Also, thanks for porting Dhall to Rust! :) |
This comment has been minimized.
This comment has been minimized.
|
I have a pull request out for this here: #30 If you have time could you take a look at that and see if it introduces any new shift-reduce or reduce-reduce conflicts? |
This comment has been minimized.
This comment has been minimized.
|
That solves it. Doing a one-to-one translation still produces a shift/reduce error between the two Thanks! |
nanotech commentedMar 11, 2017
Typed lists and optionals are a different syntax construct than normal type ascription and bind tighter than expected:
The function arrow also binds tighter than Haskell’s, although that’s only a bit suprising and not an internal inconsistency:
I ran into this while trying to port the new unannotated list syntax to my Dhall implementation in Rust. I’m using the LALRPOP library for parsing and hit a shift/reduce conflict between the annotated list rule and the top level type ascription rule after parsing an
'[' Elements ']'token sequence.I’m sure there’s a way to fix the conflict that I haven’t discovered yet, but it would be nice if Dhall’s grammar could be as straightforward to translate into an LALR(1) or LR(1) grammar as it was previously. I’ve experimented with a branch that only has the single top parse rule for type ascription and merges the annotation type into the list AST after parsing, but that would parse differently from your library.
Thanks for the nice language!