
#10460: Allow foreign prim to return Any
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: feature | Status: new
request | Milestone: 7.12.1
Priority: normal | Version: 7.11
Component: Compiler | Operating System: Unknown/Multiple
(Type checker) | Type of failure: GHC rejects
Keywords: | valid program
Architecture: | Blocked By:
Unknown/Multiple | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
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