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

RPC effect #4

Open
isovector opened this issue May 12, 2019 · 1 comment
Open

RPC effect #4

isovector opened this issue May 12, 2019 · 1 comment
Labels
idea effects i want to exist

Comments

@isovector
Copy link
Member

Consider this:

We can automatically provide RPC stubs for any first-order effect, and for any second-order effect that is called with StaticPtrs.

How?

data RPC c m a where
  DoRPC :: c -> RPC c m c

where c is some type for marshalling, maybe a Data.JSON.Value or a ByteString or something.

We can then transform effects into RPC calls:

runAsRPC :: (ToRPC e c, Member (RPC c) r) => Sem (e ': r) a -> Sem r a
runAsRPC = interpret $ fmap fromRPC . doRPC . toRPC

where the marshalling details come generically from the ToRPC instance, possibly built around the one-liner machinery.

This lets you send RPC calls; to respond to them you can do something with an RPC handler that receives RPC messages and then uses intercept to respond to them. I haven't hashed out the details of this bit yet, but it seems super doable.

@isovector isovector added the idea effects i want to exist label May 12, 2019
@isovector
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea effects i want to exist
Projects
None yet
Development

No branches or pull requests

1 participant