-
Notifications
You must be signed in to change notification settings - Fork 264
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
Allow blocks to appear as elements in lists and tuples #2415
Conversation
Just (block, n) -> do | ||
S.put (env { layout = drop n (layout env), opening = Just block }) | ||
let opens = [Token (Reserved close) pos1 pos2] | ||
pure $ replicate (n-1) (Token Close pos1 pos2) ++ opens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The n-1
here is key. Close as many blocks as necessary to get us back to the bracket block.
@@ -84,9 +84,9 @@ effectList = do | |||
|
|||
sequenceTyp :: Var v => TypeP v | |||
sequenceTyp = do | |||
open <- reserved "[" | |||
open <- openBlockWith "[" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's a bit weird that blocks can appear in list types, but there aren't any block type elements at this level anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I left a few suggestions that I think might be good improvements in the Lexer
. Have a look. I also added one additional test case, directly to the transcript.
I removed ready-to-merge so you can review my comments and address and merge at your leisure.
Co-authored-by: Paul Chiusano <paul.chiusano@gmail.com>
Co-authored-by: Paul Chiusano <paul.chiusano@gmail.com>
Fixes #2258.
This changes and unifies the way the parser handles brackets—namely parentheses (
()
) and square brackets ([]
)—and commas (,
) inside them. A bracket now opens a block, and the corresponding closing bracket closes it. Any comma between brackets also closes any inner blocks that were opened inside the brackets.As a result, blocks can now appear as elements in lists and tuples, so this is valid syntax:
as is
This incidentally also adds support for redundant commas in tuples, like
(,"one",,"two",)
, making that syntax consistent with lists.