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

Strengthen internal types and laws via gdp? #284

Open
spacekitteh opened this issue Nov 25, 2019 · 6 comments
Open

Strengthen internal types and laws via gdp? #284

spacekitteh opened this issue Nov 25, 2019 · 6 comments
Labels
custom errors enhancement New feature or request polish make the libary joyful t use

Comments

@spacekitteh
Copy link
Contributor

(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 library gdp. 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?

@isovector
Copy link
Member

I'm wildly excited about gdp. What did you have in mind?

@spacekitteh
Copy link
Contributor Author

Well, I'm not sure - Polysemy's internals are still a mystery to me. Perhaps one starting point might be NonDet?

@KingoftheHomeless
Copy link
Collaborator

KingoftheHomeless commented Nov 25, 2019

NonDet's probably not a good idea seeing how runNonDet is broken.

Maybe the Weaving machinery, and what makes use of it? I.e. Tactics and Final. Then again, from what I can tell Effect Handlers In Scope doesn't define any laws for the weave abstraction.

@spacekitteh
Copy link
Contributor Author

NonDet's probably not a good idea seeing how runNonDet is broken.

That's exactly why I suggested it :D

@isovector
Copy link
Member

It's not immediately clear to me how to throw gdp at polysemy. I'd appreciate some hints in that direction!

@spacekitteh
Copy link
Contributor Author

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.

@TheMatten TheMatten added custom errors enhancement New feature or request polish make the libary joyful t use labels Jan 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom errors enhancement New feature or request polish make the libary joyful t use
Projects
None yet
Development

No branches or pull requests

5 participants
@isovector @spacekitteh @TheMatten @KingoftheHomeless and others