Opened 10 months ago

Last modified 8 days ago

#9079 new bug

Foreign.C.Types in haskell2010

Reported by: tensor5 Owned by: ekmett
Priority: normal Milestone:
Component: Core Libraries Version: 7.8.2
Keywords: Cc: core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

According to Haskell 2010, a marshallable foreign type has to be a newtype of a basic type with exposed constructor. Why constructors are not exposed in the module Foreign.C.Types from haskell2010?
When I replace base with haskell2010 in

module Test where

import Foreign.C

foreign import ccall unsafe "sys/mount.h umount" umount :: CString -> IO CInt

I get

Unacceptable result type in foreign declaration: IO CInt
When checking declaration:
  foreign import ccall unsafe "static sys/mount.h umount" umount
    :: CString -> IO CInt

Change History (7)

comment:1 Changed 10 months ago by simonpj

  • Cc core-libraries-committee@… added
  • Resolution set to worksforme
  • Status changed from new to closed

Interesting. Foreign.C.Types does export CInt(..). And compiling the module you show works just fine for me:

bash$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.2

bash$ ghc -c T9079.hs -fforce-recomp
bash$ cat T9079.hs
module T9079 where

import Foreign.C

foreign import ccall unsafe "sys/mount.h umount" umount :: CString -> IO CInt

Perhaps you aren't using 7.8.2? I'll close as "worksforme" but if you disagree then please do re-open with more details.

Simon

comment:2 Changed 10 months ago by tensor5

I'm talking about compiling using haskell2010:

ghc -package haskell2010 -hide-package base Test.hs

As I see from this source the constructors for C types are not exposed.

comment:3 Changed 10 months ago by tensor5

  • Resolution worksforme deleted
  • Status changed from closed to new

comment:4 Changed 10 months ago by hvr

I believe this is related to the breaking change that went into GHC 7.6.1:

Warning: newtype `CInt' is used in an FFI declaration,
         but its constructor is not in scope.
         This will become an error in GHC 7.6.1.

comment:5 Changed 10 months ago by simonpj

Well, this looks to me like a bug in the Haskell 2010 report

  • Section 8.4.2 says that newtypes must have their constructors visible, and claims that Foreign.C.Types follows this convention.
  • But Chapter 28 which shows Foreign.C.Types manifestly does not follow this convention.

That looks like an outright contradiction.

I think we should export all the data constructors in Foreign.C.Types in the haskell2010 package. Does anyone disagree?

Meanwhile, I'm adding Simon M to the cc list, as editor of the H2010 report.

Autin: could you act on this after a suitable delay?

Simon

comment:6 Changed 5 months ago by thoughtpolice

  • Component changed from libraries/haskell2010 to Core Libraries
  • Owner set to ekmett

Moving over to new owning component 'Core Libraries'.

comment:7 Changed 8 days ago by ekmett

We've dropped core library support for the haskell2010 package, due to #9590, but this still seems actionable.

Herbert has been exploring ways to get users who really want it a fully compliant haskell2010 package, and this unfortunate contradiction seems like it'd still impact his efforts on that front.

Note: See TracTickets for help on using tickets.