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.
Consider this:
We can automatically provide RPC stubs for any first-order effect, and for any second-order effect that is called with
StaticPtr
s.How?
where
c
is some type for marshalling, maybe aData.JSON.Value
or aByteString
or something.We can then transform effects into RPC calls:
where the marshalling details come generically from the
ToRPC
instance, possibly built around theone-liner
machinery.This lets you send RPC calls; to respond to them you can do something with an
RPC
handler that receivesRPC
messages and then usesintercept
to respond to them. I haven't hashed out the details of this bit yet, but it seems super doable.