Change nested record update syntax and fix bug with depth > 2#2580
Conversation
| let path' = path ++ [key] | ||
| updates = goLayer path' <$> M.toList branch | ||
| accessor = foldr Accessor val path' | ||
| accessor = foldl (flip Accessor) val path' |
There was a problem hiding this comment.
This is the bug fix. Apparently I never tested with depth > 2. It would generate the accessor in reverse.
There was a problem hiding this comment.
it's just a little thing, but foldl' is preferrable to foldl in almost all cases
| l.bar.baz == r.bar.baz && | ||
| l.bar.qux == r.bar.qux | ||
| l.bar.qux.lhs == r.bar.qux.lhs | ||
| l.bar.qux.rhs == r.bar.qux.rhs |
|
For #1807 |
| parseHole = Hole <$> holeLit | ||
|
|
||
| parsePropertyUpdate :: TokenParser (NonEmpty PSString, Expr) | ||
| parsePropertyUpdate :: TokenParser [(NonEmpty PSString, Expr)] |
There was a problem hiding this comment.
Why not just parse the tree structure directly here? It seems like now you're turning it back and forth into a list of paths.
|
I like the new syntax, thanks! |
|
I'm pretty much rewriting it from scratch now. 😛 |
|
Now that I'm building the tree earlier, I can't use Map - I need information about the order when processing the wildcards (they correspond to lambdas from left-to-right). |
paf31
left a comment
There was a problem hiding this comment.
Looks great, thanks! Is anything else left to do here?
|
The parse error is bad when you have duplicate keys: In the parser I wrote an error saying |
|
The |
|
Ah ok. So solving this won't be trivial, but it's possible. We'd have to combine records and record updates into a single parser, I think. |
|
I just tried to compile collapse ∷ Card.Model → Array Card.Model → Maybe Card.Model
collapse parent child = case parent, child of
CM.Draftboard { layout }, [ cm@CM.Draftboard { layout: subLayout } ] → do
cursor ← Pane.getCursorFor (Just deckId) layout
layout' ← Pane.modifyAt (const subLayout) cursor layout
pure $ CM.Draftboard { layout: layout' }with: I guess it's related to the recent accessor chain parser changes? If it doesn't belong here lmk and I'll open a separate issue. |
|
@kritzcreek would you also be able to try this with the latest commit in this pull request? |
|
@LiamGoodacre Still get the same error with this branch. |
|
@kritzcreek actually I think what you're seeing is related to #2559 |
|
Thanks for the help |
|
That seems like a bug, doesn't it? Parens aren't required like that for operator aliases. |
|
@kritzcreek @natefaubion Could we move this conversation to either #2559 or a new issue, thanks :) |
No description provided.