Re: Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?

2019-11-09 Thread Christopher Done
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, #). On Tue, 5 Nov 2019 at 15:18, Christopher

Re: Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?

2019-11-05 Thread Christopher Done
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 []

Re: Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?

2019-11-05 Thread Csaba Hruska
Hi, I've also observed that in the final lowered STG the State# is always passed to effectful primops and FFI calls, but the returning new State# is removed from the result type. The State# has VoidRep representation in in cmm, so no register gets allocated for it and eventually the State#

Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?

2019-10-28 Thread Christopher Done
Hi all, I tried compiling this file: {-# LANGUAGE NoImplicitPrelude #-}-- | Demonstrate various use of the FFI.module Foreign whereimport Foreign.Cforeign import ccall "math.h sin" sin :: CDouble -> CDoubleit :: CDoubleit = sin 1 And I’ve noticed that the annotated type given for this foreign