
#11032: Missing result type handling for State# s in foreign import prim. -------------------------------------+------------------------------------- Reporter: ekmett | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 (FFI) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I've been using `foreign import prim` for a while now to craft custom primops on an as-needed basis. Attempting to write {{{#!hs {-# 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11032 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler