-
Notifications
You must be signed in to change notification settings - Fork 1
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
Simplify and openapi-ify /api/program #180
Conversation
Whilst the code is not ready for review, I did want to raise two questions:
@dhess: thoughts? |
The old API is irrelevant, so don't make any compromises on the new API to accommodate it. If the old API continues to work (for some definition of "work"), that's fine, but if it doesn't, we can just remove the code and/or Servant endpoint. (Over time the old API should go away entirely.)
Hmm, that's an interesting point that I hadn't considered re: alternate ASTs for, e.g., GHCJS-based frontends. (We might even be able to take advantage of that ourselves in some distant future.) Thinking ahead, we could offer the more robust ASTs as a different API endpoint. Therefore, let's keep a 1:1 relationship between |
c5d134c
to
477fcd8
Compare
This is now ready for review. My main question is over serialisation of |
776f221
to
e597d96
Compare
e597d96
to
c484db3
Compare
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.
Looks good, nothing major.
c484db3
to
2d0865b
Compare
@dhess : I believe you said that you wanted to review this PR.
|
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.
Only some minor comments & questions. Looks good to me, thanks!
primer/src/Primer/API.hs
Outdated
|
||
instance ToJSON Prog | ||
|
||
-- | This type is the api's view of a 'Def' |
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.
Doesn't this beg the question? :)
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.
Thanks! This used to be called APIDef
, but the comment bitrotted in the name change. I should say ... of a 'Primer.Core.Def'
, or whereever it is defined. I should also check the other api types, as I did a similar transition for something else also.
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.
(There should be a way to a haddock lint pass, if there isn't already.)
<$> Map.toList (progDefs p) | ||
} | ||
|
||
-- | A simple method to extract 'Tree's from 'Expr's. This is injective. |
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.
Is there a category theory-ish library on Hackage that we can use to wrap the Tree
output type with an injective assertion/invariant?
3f21582
to
4fde3fb
Compare
4fde3fb
to
c485e6c
Compare
bors merge |
Merge conflict. |
Huh, I obviously don't understand bors. I had hoped that since a [Context: I didn't just rebase on |
Unfortunately, the Bors details page isn't very helpful: https://bors.hackworth-corp.com/batches/196 I'll try to look in the logs. |
Unfortunately, the logs were useless. |
c485e6c
to
9284396
Compare
I have rebased onto c81d082 and will test a bors merge. However, I expect this to still merge conflict. |
tryMerge conflict. |
This never fails. Let's expose that fact in the API.
i.e. we now have '1' and '"foo"' instead of '{unID:1}' and '{unName:"foo"}' Almost all of this commit is testcase churn because of this change.` The change to ToJSONKey enables us to output 'Map ID _' from our API (whilst having correct OpenAPI3 documentation), since the map will be serialized as an object, where the keys are 'show' of the IDs. However, we decide to keep our list-based representation, as documented in a comment. Note that this only applies to the "new api", and not to the serialization test fixtures.
We also add regression tests. [Historical note: this patch series was authored before Gen.Core.Raw obtained better coverage. This is the reason the non-injectivity was not discovered earlier, and the reason for the reliance on unit tests here.]
9284396
to
837f037
Compare
Rebased onto main. Bors should now be happy |
Build succeeded: |
Did you gain any insight on this as to why Bors rejected the earlier merge and the rebase on c81d082? |
No. I guess that what Bors considers a "merge conflict" is stricter than what (my local configuration of) git will automatically merge. However, I couldn't easily find any information about this, other than that Bors just calls the github api https://docs.github.com/en/rest/reference/repos#merge-a-branch |
Simplify the return types from
/api/program
, and port to openapi3.We drastically simplify by returning a rose tree where each node is labeled with
an ID and a textual label, instead of a full AST.
The rationale is that a frontend is mostly concerned with rendering and does not
need to know about the complexity of the full AST. This initial iteration is obviously
oversimplified and is expected to expand in the future.