Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #10505
Closed
Open
Created Jun 10, 2015 by imz@trac-imz

more specific types in the generated *_stub.h files

Having a declaration like:

foreign export ccall "respond" respond :: CWString -> IO CWString

all the types in the corresponding _stub.h are HsPtr.

Wouldn't it be possible to write more specific types reflecting my expectations, i.e., wchar_t *?

It would be nice in order to signal automatically to the C code which uses the Haskell functions that the types of the Haskell functions changed. In simple cases, one could simply include the stub.h, and get automatically an error if the C code doesn't match the new types.

I've tried using a CTYPE pragma (cf. #2979 (closed) , #8222 (closed) , and https://mail.haskell.org/pipermail/haskell/2012-February/023155.html ) on a newtype to get such results:

newtype {-# CTYPE "wchar_t *" #-} CWString' = CWString' CWString
foreign export ccall "respond" respond :: CWString'  -> IO CWString

but that still produces HsPtr. (Well, I see, the CTYPE pragma was mostly intended for imports rather than exports.)

Edited Mar 10, 2019 by imz
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking