Skip to content

Feature record update#337

Open
julian-berbel wants to merge 5 commits into
masterfrom
feature-record-update
Open

Feature record update#337
julian-berbel wants to merge 5 commits into
masterfrom
feature-record-update

Conversation

@julian-berbel

@julian-berbel julian-berbel commented Jun 17, 2021

Copy link
Copy Markdown
Member

Fixes #336.

Thought of using FieldAssignment at first but got dissuaded by the fact that you can update multiple fields per record update.

I didn't use an expression for the update's field name as it's not quite the same as other References (i.e. it cannot be parameterized). That being said, in retrospective, that might be too strongly tied to haskell's way of doing it? How is this supposed to work with rename and replace? Not so sure about this one!

Comment thread spec/GenericSpec.hs
it "works with RecordUpdate" $ do
uses (named "f") (RecordUpdate (Reference "f") [("g", Reference "h")]) `shouldBe` True
uses (named "h") (RecordUpdate (Reference "f") [("g", Reference "h")]) `shouldBe` True
uses (named "g") (RecordUpdate (Reference "f") [("g", Reference "h")]) `shouldBe` False

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not married to this. See description.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure, too.

I would take the same path as with assignments. If we are considering assignment as usage, then should we consider record update's assignee as a usage too

@flbulgarelli flbulgarelli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks quite good. My main concerns are about the visitor module: we should at least update the documentation of the visit pattern.

However, I am unsure about the motivation of this feature. Are we actually going to introduce new expectations for this RecordUpdate? Or do we just need the inner contents of the record update to be parsed? May an Other here also solve the problem?

Comment thread spec/GenericSpec.hs
it "works with RecordUpdate" $ do
uses (named "f") (RecordUpdate (Reference "f") [("g", Reference "h")]) `shouldBe` True
uses (named "h") (RecordUpdate (Reference "f") [("g", Reference "h")]) `shouldBe` True
uses (named "g") (RecordUpdate (Reference "f") [("g", Reference "h")]) `shouldBe` False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure, too.

I would take the same path as with assignments. If we are considering assignment as usage, then should we consider record update's assignee as a usage too

normalizeSwitchCases ops = map (\(e1, e2) -> (normalize ops e1, normalize ops e2))
normalizeRecordUpdates ops = map (\(i, e) -> (i, normalize ops e))
normalizeTryCases ops = map (\(p, e) -> (p, normalize ops e))
normalizeSwitchCases ops = map (\(e1, e2) -> (normalize ops e1, normalize ops e2))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could generalize those tree functions now. The first two are the same, and are mostly the same in all files.

@flbulgarelli

Copy link
Copy Markdown
Member

Thought of using FieldAssignment at first but got dissuaded by the fact that you can update multiple fields per record update.

Agree

@flbulgarelli

Copy link
Copy Markdown
Member

I didn't use an expression for the update's field name as it's not quite the same as other References (i.e. it cannot be parameterized). That being said, in retrospective, that might be too strongly tied to haskell's way of doing it?

I am unsure about this one, too. Do we have any other examples in other languages?

In any case, rename and replace don't currently target record's field names.

@julian-berbel

Copy link
Copy Markdown
Member Author

However, I am unsure about the motivation of this feature. Are we actually going to introduce new expectations for this RecordUpdate? Or do we just need the inner contents of the record update to be parsed? May an Other here also solve the problem?

I... I forgot Other could come with an expression. That could work too!

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

Successfully merging this pull request may close these issues.

Haskell - Expectativa Uses: no detecta usos en record syntax

2 participants