-
Notifications
You must be signed in to change notification settings - Fork 25
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
Reducer real life type checking example to build a library #900
Conversation
✅ Deploy Preview for squiggle-components ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for squiggle-documentation ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Codecov Report
@@ Coverage Diff @@
## develop #900 +/- ##
===========================================
- Coverage 57.96% 57.85% -0.12%
===========================================
Files 73 74 +1
Lines 4094 4114 +20
===========================================
+ Hits 2373 2380 +7
- Misses 1721 1734 +13
Continue to review full report at Codecov.
|
@OAGr I have a strong feeling that we need lenses to extract data from deep nested types/records: https://github.com/Astrocoders/lenses-ppx |
I like lenses, but am pretty weary of adding PPX. The rescript people recommend fairly strongly against them. "If you are new to ReScript and plan to write some production code (instead of just playing it), you are not encouraged to investing your time in PPX or PPX based technologies." If we do add them, it would be good to really try to restrict their use, so that if they break later on, we're not in too bad a state. |
I see your point... Due to the nature of expression values, there might be a custom solution. |
@OAGr Curious about your comments |
packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_switch_replacement_test.res
Show resolved
Hide resolved
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.
Just looked through this. It took me a while (to get to it and mainly understand it).
Overall, I like it. It seems simple enough, should be easy to incorporate with the Function Registry code. I left one comment, but generally happy to merge.
packages/squiggle-lang/__tests__/Reducer/Reducer_Type/Reducer_Type_switch_replacement_test.res
Show resolved
Hide resolved
As an example, it's good for merging. |
This is a real life example/guide/inspiration of how to replace switch statements with official function types.
A complete dispatch function is implemented in a unit test. Providing an example of deep record checking (plot).
Also "any" type is added for now so that complete module libraries can be written in this fashion.
Better see the colored version: https://github.com/quantified-uncertainty/squiggle/pull/900/files#diff-22fa54f9384977cbf9012a9de088d6ed9df7974725e8dfd635163261280ef4ec
If all the functions are typed then switching to the fully typed version of Squiggle will be smoother.
It's clear that in real life we need a bundle of extract functions to drill into records and arrays. Not provided yet.
Note: I later found out that E.O2.default(chain... should not be used because it calls the chain every time unnecessarily.