-
Notifications
You must be signed in to change notification settings - Fork 73
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
Strengthen internal types and laws via gdp
?
#284
Comments
I'm wildly excited about gdp. What did you have in mind? |
Well, I'm not sure - Polysemy's internals are still a mystery to me. Perhaps one starting point might be NonDet? |
Maybe the |
That's exactly why I suggested it :D |
It's not immediately clear to me how to throw gdp at polysemy. I'd appreciate some hints in that direction! |
Here's one example: when you interpret an effect, you may add it to a list of effects which have already been handled. So, say I create an effect which must not be handled after an effect which is used for communicating with another process - I could consult the list of already handled effects, and raise a custom type error. Another example: You might want to prove that some effects are commutative with eachother in the effect row, and provide some rewrite rules such that the handlers are rearranged into the most efficient, yet semantically equivalent order. I've found using 'Fact' quite useful for accumulating invariants, but until GHC 8.10 lands with the dictionary patch, it might not be zero-cost. |
(Discussion)
So, I've been thinking about how to instil confidence in the higher-order nature of Polysemy. In addition to the
HasLaws
machinery that was recently added, an orthogonal approach which might be quite useful (for internal modules, anyway) is to use the librarygdp
. If you aren't familiar with this, it is a handy library for zero-runtime-cost refinement typing entirely in Haskell, and much lighter-weight than, say,singletons
.I'm currently in the process of strengthening the internals of my SAT solver with it, you can see a bit of it e.g. here https://gitlab.com/spacekitteh/cosmothought/blob/master/thought-effects/src/Logic/Symbolic/SAT/Representations/CNF.hs
What does everyone think? Would you be up for trying it out?
The text was updated successfully, but these errors were encountered: