[Haskell-cafe] ccall vs capi

Julian Ospald hasufell at hasufell.de
Sun Jun 13 21:18:42 UTC 2021


Hi,

recently during a ghcup release, we stumbled over yet another `ccall`
bug on Darwin: https://github.com/biegunka/terminal-size/pull/16

This took Ben some time to debug (thanks again) and it isn't always
clear with such
bugs whether something is wrong with GHC/RTS/GC or a library, so this
can be a time-sink.

It's also not the first time it happened:
* https://github.com/haskell/unix/pull/110#issuecomment-613384845
* https://github.com/hasufell/hpath/commit/74d686547e67da3eeae327c84c63f83833205890

I can't say that I fully understood what the exact difference here is
and why it seems to matter much more on Darwin than on other systems. So
I think it would be helpful if we could come up with:

1. a clear description of the differences of ccall vs capi
2. an explanation why ccall can lead to terrible bugs on darwin
3. a guideline of when using one over the other is appropriate

Not everyone deals with ffi on a regular basis, so I hope the experts
here can shed some light!

Cheers,
Julian


More information about the Haskell-Cafe mailing list