Missing result type handling for State# s in foreign import prim.
I've been using foreign import prim
for a while now to craft custom primops on an as-needed basis.
Attempting to write
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnliftedFFITypes #-}
{-# LANGUAGE GHCForeignImportPrim #-}
{-# LANGUAGE ForeignFunctionInterface #-}
foreign import prim "pinThreadzh" pinThread# :: State# s -> (# State# s, Int#, Int# #)
foreign import prim "unpinThreadzh" unpinThread# :: State# s -> State# s
threw me for a loop when it didn't work.
The former works fine. The latter complains that State# s
isn't a valid result type!
src/Concurrent/Internal/Thread.hs:23:1:
Unacceptable result type in foreign declaration:
‘State# s’ cannot be marshalled in a foreign call
When checking declaration:
foreign import prim safe "static unpinThreadzh" unpinThread#
:: State# s -> State# s
Builtin primitives work this way all the time, so I'm guessing we just missed it in a case statement somewhere inside the compiler when dealing with foreign import prim
support.
I can likely hack around it by giving back something like (# State# s #)
for now but that is a rather unsatisfying solution.
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (FFI) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |