Haskell interop


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 :slight_smile:

thanks !

Your best bet is to use RPC.

Both languages have interoperability with C.
That would be another, even more ugly, bet.

Maybe some hints there:

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 :slight_smile: 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:

  1. cross-address-space context-switching
  2. serializing explicitly via a buffer, as opposed to serializing implicitly via translation functions (that would translate OCaml heap graphs into Haskell heap graphs, etc).
  3. most of the memory-ownership/lifetime issues for the two approaches are similar.
  4. 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.