Are there any ffi/plan on adding ffi?
Closed this issue · 4 comments
You can already add foreign functions for OCaml, is that what you're asking for?
Yes! Sorry, but I cannot find the doc for how to do so, can you give me an example, or do I have to read through the source code?
Briefly, if you'd like to add to Eff a function which is implemented in OCaml, you add it to the list values
at https://github.com/matijapretnar/eff/blob/master/src/runtime/external.ml#L202
This is an association list, i.e., a list of pairs (s, v)
where s
is a string and v
is an Eff value. In external.ml
you will find examples and also helper functions that let you construct suitable wrappers.
You need to make the external function visible in Eff. You do this by declaring:
external foo : t = "foo"
where foo
is the name of the function and t
is its Eff type. An example to look at is float_of_int
in pervasives.eff
.
If you tell us a bit more what you are after, we can be more specific.
Thx! I think I am good for now and will just play with it myself.