Skip to content

regression: acceptable foreign result types

The following short file is rejected:

import Foreign.Ptr
foreign import ccall "wrapper" foo :: IO (FunPtr ())

The error is:

test.hs:2:1:
    Unacceptable type in foreign declaration: IO (FunPtr ())
    When checking declaration:
      foreign import ccall safe "wrapper" foo :: IO (FunPtr ())

However, my reading of the 2010 Report suggests this should be acceptable. Specifically:

  • Prelude.IO t is a marshallable foreign result type when t is a marshallable foreign type,[[BR]]
  • all basic foreign types are marshallable foreign types, and[[BR]]
  • FunPtr a is a basic foreign type for all a.

(Political note: I include this chain of reasoning not because I think others too stupid to recreate it, but because I think it likely that I am not reading the Report correctly, and want to make it easy to detect and correct any misconceptions I have.)

Trac metadata
Trac field Value
Version 7.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information