Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?
Christopher Done
chrisdone at gmail.com
Sat Nov 9 16:10:10 UTC 2019
For anyone interested, here's a complete list of all foreign imports at the
STG level from base and integer-simple:
https://gist.github.com/chrisdone/24b476862b678a3665fbf9b833a9905f
They all have type (# State# RealWorld #) or (# State# RealWorld,
<something> #).
On Tue, 5 Nov 2019 at 15:18, Christopher Done <chrisdone at gmail.com> wrote:
> Aha, thanks Csaba. So I’m not losing my marbles. The AST has a type
> signature of the “initial” but implements the “lowered”. So with
> -ddump-stg we can observe it:
>
> The version claimed in the type signature (returning a tuple):
>
> Foreign.it :: Foreign.C.Types.CDouble
> [GblId] =
> [] \u []
> case ds_r1HA of {
> GHC.Types.D# ds2_s1HW [Occ=Once] ->
> case __pkg_ccall_GC main [ds2_s1HW GHC.Prim.realWorld#] of {
> (#,#) _ [Occ=Dead] ds4_s1I0 [Occ=Once] -> GHC.Types.D# [ds4_s1I0];
> };
> };
>
> The final “lowered” version:
>
> Foreign.it :: Foreign.C.Types.CDouble
> [GblId] =
> [] \u []
> case ds_r1HA of {
> GHC.Types.D# ds2_s1HW [Occ=Once] ->
> case __pkg_ccall_GC main [ds2_s1HW GHC.Prim.realWorld#] of {
> Unit# ds4_s1I0 [Occ=Once] -> GHC.Types.D# [ds4_s1I0];
> };
> };
>
> Cheers!
>
> Chris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20191109/c4191b5c/attachment.html>
More information about the ghc-devs
mailing list