Skip to content
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

Removing asVC' hack with replacement QuantityDicts #2952

Merged
merged 10 commits into from
Apr 18, 2022

Conversation

peter-michalski
Copy link
Collaborator

@peter-michalski peter-michalski commented Mar 10, 2022

For issue #1166

@peter-michalski peter-michalski changed the title Removing asVC' hack with replacement QuantityDicts - Issue #1166 Removing asVC' hack with replacement QuantityDicts Mar 10, 2022
@@ -185,7 +189,7 @@ interpY = funcDef "interpY"
]

interpZ :: Func
interpZ = funcDef "interpZ"
interpZ = funcDef (showUID U.interpZ)
Copy link
Collaborator

@balacij balacij Mar 11, 2022

Choose a reason for hiding this comment

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

To continue the discussion we had on Teams here a bit, showUID (something that shouldn't really exist outside of ChunkDB debugging code) usage here is only desired because we want it to rely on (& align with) the information from the newly created QuantityDicts (I guess a more appropriate way to get the function name would be a "showSymbol"-like function for the implementation-stage name of the interpZ QuantityDict), but I think this would be best "cleaned up" if/when we place Funcs inside of the ChunkDBs. As they are right now, we aren't able to place them in the ChunkDBs because (a) they don't have UIDs, and (b) the ChunkDBs would require a bit more effort for us to be able to place Funcs inside of ChunkDBs so that we can still link the QuantityDict and the Func (maybe #2873).

Copy link
Owner

Choose a reason for hiding this comment

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

Using a hacked up showSymbol-like function would be quite a bit superior to using showUID. It would at least be pulling from the 'right' bucket of information.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, that makes sense.

Regarding the type of the symbol, should it really be a String? Specifically, is there any worth in changing it to the "Implementation-level Symbol"?

If we choose String, I think we have ~2 options:

  1. figure out a way to convert the "Implementation-level Symbol" into a Doc/Text (this should already exist somewhere I believe), and then into extract it into a String, or
  2. roll our own "Symbol -> String" function (of course, this creates potential room for misalignment with the existing Symbol -> Doc/Text functions)

Copy link
Owner

Choose a reason for hiding this comment

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

No, it doesn't have to be String. Thinking about it, it should indeed be implementation-level symbol. Well spotted!

Copy link
Collaborator

@balacij balacij Mar 29, 2022

Choose a reason for hiding this comment

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

Thank you. That sounds good. In that case, I think it would be out of scope for this PR; continuing on #2959.

@@ -159,7 +163,7 @@ extractColumnCT = funcDef "extractColumn" "Extracts a column from a 2D matrix"
]

interpY :: Func
interpY = funcDef "interpY"
interpY = funcDef (showUID U.interpY)
Copy link
Owner

Choose a reason for hiding this comment

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

Surely there's another field than UID in U.interpY which also have value "interpY" that could be used? Of this whole change, this is the one bit that sticks out as a hack, all the rest seems great.

Copy link
Collaborator Author

@peter-michalski peter-michalski Mar 29, 2022

Choose a reason for hiding this comment

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

@JacquesCarette @balacij I have made the requested changes in 17d3425.

Copy link
Owner

Choose a reason for hiding this comment

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

You have - but the changes are too "brute force". You most definitely should not be importing HughesPJ into any example! The right thing to do is to write an appropriate function (that does what you just coded up) somewhere in an appropriate Drasil package, and then call it here. Figuring out the right signature is going to be a fun design problem.

Copy link
Collaborator Author

@peter-michalski peter-michalski Mar 29, 2022

Choose a reason for hiding this comment

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

@JacquesCarette would a showSymb-like function be helpful in Drasil? (Placed into Drasil/Symbol/Helpers.hs)

showSymb :: Symbol -> String
showSymb a = render $ symbolDoc a

This would allow for the removal of HughesPJ from the example

interpZ :: Func
interpZ = funcDef (showSymb $ symbol U.interpZ Implementation)

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, such a function would be good. Probably belongs in drasil-printers. I'd be tempted to put it under the ASCII printer.

Copy link
Collaborator Author

@peter-michalski peter-michalski Mar 29, 2022

Choose a reason for hiding this comment

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

@JacquesCarette I had just edited the above comment to suggest placing it in Drasil/Symbol/Helpers.hs, but I will look into placing it into drasil-printers. The latter does sound more appropriate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JacquesCarette The requested change to add a new function has been applied in the latest commit. The PR is updated.

@@ -185,7 +189,7 @@ interpY = funcDef "interpY"
]

interpZ :: Func
interpZ = funcDef "interpZ"
interpZ = funcDef (showUID U.interpZ)
Copy link
Owner

Choose a reason for hiding this comment

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

Using a hacked up showSymbol-like function would be quite a bit superior to using showUID. It would at least be pulling from the 'right' bucket of information.

@@ -163,7 +162,7 @@ extractColumnCT = funcDef "extractColumn" "Extracts a column from a 2D matrix"
]

interpY :: Func
interpY = funcDef (showUID U.interpY)
interpY = funcDef (showSymb $ symbol U.interpY Implementation)
Copy link
Owner

Choose a reason for hiding this comment

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

These details should not be in GlassBR. The function that does

foo :: HasSymbol x => x -> String
foo x = showSymb $ symbol x Implementation

should be in drasil-printers and then called from here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JacquesCarette The requested change is added in 243618f

interpZ :: Func
interpZ = funcDef (showUID U.interpZ)
interpZ = funcDef (showSymb $ symbol U.interpZ Implementation)
Copy link
Owner

Choose a reason for hiding this comment

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

and here

@@ -180,3 +180,7 @@ fenceDocR Paren = text ")"
fenceDocR Curly = text "}"
fenceDocR Norm = text "\\|"
fenceDocR Abs = text "|"

-- | Helper for printing Symbols
showSymb :: Symbol -> String
Copy link
Owner

Choose a reason for hiding this comment

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

good start, but this only does 1/2 the job

@JacquesCarette JacquesCarette merged commit 560ab2a into JacquesCarette:master Apr 18, 2022
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.

3 participants