
#10460: Allow foreign prim to return Any -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (Type | Version: 7.11 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: | -------------------------------------+------------------------------------- Changes (by ezyang): * owner: => ezyang Old description:
Presently, we have
{{{ {-# LANGUAGE GHCForeignImportPrim #-} module Serum where import GHC.Exts
foreign import prim "chenycopy" cheneycopy :: Any -> Any }}}
induces the error
{{{ Serum.hs:5:1: Unacceptable result type in foreign declaration: ‘Any’ cannot be marshalled in a foreign call When checking declaration: foreign import prim safe "static chenycopy" cheneycopy :: Any -> Any }}}
We ought to allow a lifted value to be returned from a foreign primop; no reason not to, anyway; no reason not to, and there are plenty of built-in primops which do this.
For reference, lifted arguments were allowed in arugments in this commit:
{{{ commit e29001c9e0f73885c0b85d86c3a854519448013a Author: Joachim Breitner
Mon Mar 12 01:20:12 2012 Committer: Simon Marlow Wed Mar 14 06:01:18 2012 Allow Any as an argument type to foreign prim functions }}}
New description:
Presently, we have
{{{
{-# LANGUAGE GHCForeignImportPrim #-}
module Serum where
import GHC.Exts
foreign import prim "chenycopy" cheneycopy :: Any -> Any
}}}
induces the error
{{{
Serum.hs:5:1:
Unacceptable result type in foreign declaration:
‘Any’ cannot be marshalled in a foreign call
When checking declaration:
foreign import prim safe "static chenycopy" cheneycopy
:: Any -> Any
}}}
We ought to allow a lifted value to be returned from a foreign primop; no
reason not to, anyway; no reason not to, and there are plenty of built-in
primops which do this.
For reference, lifted arguments were allowed in arugments in this commit:
{{{
commit e29001c9e0f73885c0b85d86c3a854519448013a
Author: Joachim Breitner