[Haskell-cafe] ANNOUNCE: call-haskell-from-anything 1.0

Niklas Hambüchen mail at nh2.me
Sun Jan 31 03:30:27 UTC 2016


Heya,

I'm happy to announce a new release of call-haskell-from-anything [1],
my library for FFI-via-serialisation that allows to easily call Haskell
functions from any other language that can open shared object files
(`.so` via `dlopen()`) and has a MessagePack library available.

This is almost all programming languages; for examples for Python and
Ruby see [2].

The FFI-via-serialisation approach makes it possible to export most
functions to other languages "for free": no FFI type unpacking
boilerplate, everything that has a MessagePack instance (much easier to
write than `Storable` instances) will do.

For example if you have a function

  chooseMax :: [Int] -> Int

all you have do to make it callable is

  foreign export ccall chooseMax_export :: CString -> IO CString
  chooseMax_export = export chooseMax

Version 1.0 uses closed type families to remove the restriction that so
far, pure functions has to be wrapped into the Identity monad to be
exported:

  a -> b -> ... -> Identity r

With 1.0, this is no longer necessary. You can now export any function
of type

  a -> b -> ... -> r

to be called from your favourite Haskell contender languages (of course
those have no chance ...).

Cheers,
Niklas

[1]: https://hackage.haskell.org/package/call-haskell-from-anything-1.0.0.0
[2]: https://github.com/nh2/call-haskell-from-anything


More information about the Haskell-Cafe mailing list