Hi Lennart,
I was wondering if it wouldn't be too much trouble to support StaticPtr. Specifically the static keyword, along with deRefStaticPtr / unsafeLookupStaticPtr / StaticKey, etc. Seen here.
The environment I'm targeting (the LynxJS runtime environment) has two JavaScript interpreters (similar to react-native reanimated), where the same JS payload executes at once in each environment. It seems to be an ideal use case for StaticPtr. One interpreter has access to Swift / ObjC / Java / Kotlin code, the other to the drawing context. I've had success in serializing Haskell ADTs for transfer between processes, passing along the StaticKey, and reifying the necessary functions for evaluation in each environment (all statically known and available in the static pointer table), to perform effects. This has come at the cost of some additional monomorphization / boilerplate, but it seems to be working.
I think with MicroHs we could do better and transfer any arbitrary function (compiled dynamically to combinators, and serialized) to a different interpreter. I believe both react-native and LynxJS do something very similar (it's called "worklets") where a JS function is serialized (.toString()) and its closure is also serialized and passed along to the other interpreter (via WebWorker). eval is then invoked on it in the new environment. But for compatibility with GHC, and to not rely on Data.Dynamic constraint, the StaticPtr seems "good enough".
Tangentially, regarding JSVal, I have a local branch, it follows the primop implementation instructions as you've defined on the README.md. It does not yet support sync / async callbacks which are important for web component mounting (to ensure correct ordering on the DOM). I might make a PR shortly after the Lynx integration to continue on in that effort with whatever I have at the moment. I do still think the compilation performance and portability will be very good.
The work I'm doing w/ StaticPtr is here.
Hi Lennart,
I was wondering if it wouldn't be too much trouble to support
StaticPtr. Specifically thestatickeyword, along withdeRefStaticPtr/unsafeLookupStaticPtr/StaticKey, etc. Seen here.The environment I'm targeting (the LynxJS runtime environment) has two JavaScript interpreters (similar to
react-nativereanimated), where the same JS payload executes at once in each environment. It seems to be an ideal use case forStaticPtr. One interpreter has access to Swift / ObjC / Java / Kotlin code, the other to the drawing context. I've had success in serializing Haskell ADTs for transfer between processes, passing along theStaticKey, and reifying the necessary functions for evaluation in each environment (all statically known and available in the static pointer table), to perform effects. This has come at the cost of some additional monomorphization / boilerplate, but it seems to be working.I think with MicroHs we could do better and transfer any arbitrary function (compiled dynamically to combinators, and serialized) to a different interpreter. I believe both
react-nativeandLynxJSdo something very similar (it's called "worklets") where a JS function is serialized (.toString()) and its closure is also serialized and passed along to the other interpreter (viaWebWorker).evalis then invoked on it in the new environment. But for compatibility with GHC, and to not rely onData.Dynamicconstraint, theStaticPtrseems "good enough".Tangentially, regarding
JSVal, I have a local branch, it follows the primop implementation instructions as you've defined on the README.md. It does not yet support sync / async callbacks which are important for web component mounting (to ensure correct ordering on the DOM). I might make a PR shortly after the Lynx integration to continue on in that effort with whatever I have at the moment. I do still think the compilation performance and portability will be very good.The work I'm doing w/
StaticPtris here.