Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?
Christopher Done
chrisdone at gmail.com
Tue Nov 5 15:18:38 UTC 2019
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/20191105/793dd14d/attachment.html>
More information about the ghc-devs
mailing list