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

feat: Better example program re-use in tests. #461

Merged
merged 5 commits into from
Jun 7, 2022

Conversation

dhess
Copy link
Member

@dhess dhess commented May 17, 2022

No description provided.

@dhess dhess force-pushed the dhess/more-dsl-improvements branch 6 times, most recently from 05929c0 to e70e297 Compare May 23, 2022 13:31
@dhess dhess force-pushed the dhess/more-dsl-improvements branch from e70e297 to 6a93cb3 Compare May 26, 2022 10:38
@dhess dhess added the WIP A work in progress, not ready for merging label May 30, 2022
@dhess dhess force-pushed the dhess/more-dsl-improvements branch 3 times, most recently from 8d491ba to ee3466e Compare June 3, 2022 12:50
@dhess dhess force-pushed the dhess/more-dsl-improvements branch from 5cca2a8 to 52cab05 Compare June 6, 2022 13:34
@dhess dhess changed the title refactor: Add a mkASTDef helper function. feat: Better example program re-use in tests. Jun 6, 2022
@dhess dhess force-pushed the dhess/more-dsl-improvements branch from 52cab05 to 92bd49d Compare June 6, 2022 21:06
@dhess dhess removed the WIP A work in progress, not ready for merging label Jun 6, 2022
@dhess
Copy link
Member Author

dhess commented Jun 6, 2022

There’s more I want to do to make program/app creation more ergonomic from Haskell, but this seems like a good place to cap off this particular PR.

@dhess dhess requested a review from brprice June 6, 2022 22:34
@dhess
Copy link
Member Author

dhess commented Jun 6, 2022

Note: this has been rebased on #497, so you can ignore the first few commits.

Comment on lines +220 to +221
{ appProg = testProg
, appInit = NewApp
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be worth noting that this appInit is a lie (and thus undo will not work with this App). I suspect this also happens in other places we make a test App. The lie is benign since we will never look at this field!

IIRC you had plans shortly to revisit how we encode the "initial app", which would fix this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that functionality is next in my queue. This PR is some groundwork for that.

"^Primer.Database.Rel8.Rel8Db.runRel8Db"
]
ignoreRoots =
[ "^Primer.Core.Utils.mkASTDef"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit surprised you did not end up using this helper that has just been introduced

Copy link
Member Author

Choose a reason for hiding this comment

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

Me too. In retrospect, I wouldn't have bothered with it, but this PR has been in flight for several weeks and sometimes that's just how development goes.

I thought about going back and rewriting everything from the start, knowing that I would not need it in the end, but that would require a lot of busy work, so I had 2 practical choices: add a final commit to remove it, now that it's no longer needed, or keep it around in case it's useful in the future. I chose the latter, but I can do the former if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds fine to me. A third choice is to use it when defining the comprehensive example, but that may be slightly awkward code.

Copy link
Contributor

@brprice brprice left a comment

Choose a reason for hiding this comment

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

This looks good. I had a few minor comments above. I'm happy for this to merge when you have looked at those.

@dhess dhess force-pushed the dhess/more-dsl-improvements branch from 92bd49d to 214927a Compare June 7, 2022 11:33
dhess added 4 commits June 7, 2022 12:39
This doesn't save much typing, but the `NonEmptyList` constructor name
is annoyingly hard to remember.
We parameterize the `Primer.Examples` functions over module names, to
make them easier to reuse in tests, example DSL programs, etc.
Previously, we used this test definition verbatim in 2 different
places.
@dhess dhess force-pushed the dhess/more-dsl-improvements branch from 214927a to b93078f Compare June 7, 2022 11:40
@dhess dhess enabled auto-merge June 7, 2022 11:45
@dhess dhess added this pull request to the merge queue Jun 7, 2022
@dhess dhess merged commit 37f5f84 into main Jun 7, 2022
@dhess dhess deleted the dhess/more-dsl-improvements branch June 7, 2022 11:46
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.

2 participants