Does anyone know if there’s any working trick for interoperability with Haskell ?
I’d need to bind to the ADTs of Haskell and call a haskell function…
I have no idea if that’s even possible in theory, but anything pointer would be great
Your best bet is to use RPC.
Both languages have interoperability with C.
That would be another, even more ugly, bet.
Interesting ! I’m trying to avoid bindings to C but it’s good to know it’s an option
RPC might be a good option thank you for your answers !
A little more about the difference between FFI-via-C and RPC: the difference really boils down to three things:
- cross-address-space context-switching
- serializing explicitly via a buffer, as opposed to serializing implicitly via translation functions (that would translate OCaml heap graphs into Haskell heap graphs, etc).
- most of the memory-ownership/lifetime issues for the two approaches are similar.
- calls -back- (e.g. OCaml->Haskell->OCaml) are harder/perhaps-impossible with RPCs (well, sure, you can do it, but it requires much runtime hackery).
The biggest difference is that for small/simple cross-calls, you can avoid the performance overhead of a cross-address-space RPC. But for anything complex, you might find that it’s just too dangerous (requiring too much work to keep things memory-safe) to do it via FFI.