C++ interop - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Vincent L

Hi,
Is there a tutorial on how to write haskell code that can be called from C++ and vice versa ? With MSVC (not just gcc). Is it easy ?

Vincent L

and is it possible with stack ?

Vincent L

currently I have a .o file, not even a .dll

Vincent L

I found this https://github.com/sanderman01/chaskell however I'm struggling due to too many symbol exported

A haskell and C++ project demonstrating how to build Haskell code to a dll and call it from C++. - sanderman01/chaskell
Vincent L

Adding a .def file to the commande line fixed the issue.

Vincent L

Thank you ! Do you know how to handle struct ?

IC Rainbow

inline-c makes this almost easy:

getDrawData :: MonadIO m => m DrawData
getDrawData = liftIO do
  DrawData <$> [C.exp| void* { ImGui::GetDrawData() } |]
Vincent L

Thank for the info, will try when I have time. inline-c is a tool or a lib ?

TheMatten

It's a library with some quasiquoters