-
Notifications
You must be signed in to change notification settings - Fork 266
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
Preserve record syntax in view
and edit
#2260
Comments
There is actually some logic for this and I remember it working at one point. It just needs some debugging. -- Comes up with field names for a data declaration which has the form of a
-- record, like `type Pt = { x : Int, y : Int }`. Works by generating the
-- record accessor terms for the data type, hashing these terms, and then
-- checking the `PrettyPrintEnv` for the names of those hashes. If the names for
-- these hashes are:
--
-- `Pt.x`, `Pt.x.set`, `Pt.x.modify`, `Pt.y`, `Pt.y.set`, `Pt.y.modify`
--
-- then this matches the naming convention generated by the parser, and we
-- return `x` and `y` as the field names.
--
-- This function bails with `Nothing` if the names aren't an exact match for
-- the expected record naming convention.
fieldNames
:: forall v a . Var v
=> PrettyPrintEnv
-> Reference
-> HashQualified Name
-> DataDeclaration v a
-> Maybe [HashQualified Name] If I had to guess, the logic is too fragile if it's given a suffixified pretty print environment. |
Some more details on this. It might be that it only breaks if there are more than 2 fields? |
I made a transcript and it fails for all the examples I gave it (regardless of number of fields). There is a case where records do work, but I haven't been able to consistently find it. Here's the transcript: https://gist.github.com/hojberg/3d55566ac55cc76314dc73119bd63a07 So cc @runarorama |
I'm bumping into the same
|
Record syntax are sugar that helps create a bunch of accessor functions, but the syntax is lost when
view
ed oredit
ed. This makes it very hard to:The goal of this ticket is to come up with a record solution.
The text was updated successfully, but these errors were encountered: