Opened 5 years ago

Last modified 2 years ago

#9700 new feature request

Support C structures in Haskell FFI

Reported by: Yuras Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D252
Wiki Page:


This ticket is for tracking progress on CStructures language extension proposal.

The idea is to support C structures in Haskell FFI. See wiki for details.

If it will be accepted, I'm going to implement it in few steps. The first one is to support structures as return value. Platform specific part for that is already implemented, see Phab:D252

Change History (7)

comment:1 Changed 5 years ago by Yuras

Owner: set to Yuras

comment:2 Changed 5 years ago by Yuras

Owner: Yuras deleted

There is no chance that I'll catch 7.10 release, I'm stuck in type checker.

I'm unassigning the ticket in case someone else wants to try. Probably someone with better knowledges of ghc internals will be able to finish implementation. Anyway, I have ~1 year till 7.12 to find my way into the code.

comment:3 Changed 5 years ago by carter

could you describe what you're stuck on? happy to try to help if you can explain where you're stuck.

comment:4 Changed 5 years ago by svenpanne

Hmmm, I think the wiki page is confusing C types and Haskell types:

  • If one wants to bind to a C structure containing int/char/float/..., one has to use CInt/CChar/CFloat/... on the Haskell side.
  • If one wants to access Haskell stuff containing Int/Char/Float, one has to use HsInt/HsChar/HsFloat/... on the C side.

Any kind of structure marshaling can't change anything about that, there's no portable correspondence between the types in both worlds.

comment:5 Changed 5 years ago by Yuras

carter: thank you. Unfortunately I already flushed the context out of my mind a number of days ago. But I promise to return to this feature request eventually.

svenpanne: Yes, I believe you are correct. Probably it should not mention Int, Char, Float, etc at all. Feel free to fix it. Thanks for taking a look!

And just for the record: I still think the low level part, covered by D252, is useful on itself. Please consider merging it into 7.10. At least I appreciate any feedback. I raised that question in a email in ghc-dev few weeks ago, but got no response.

comment:6 Changed 2 years ago by sboosali

any update?

comment:7 in reply to:  6 Changed 2 years ago by Yuras

Replying to sboosali:

any update?

I'm afraid this proposal is dead. Here is the code rebased over ghc-8.0 in case anyone wants to take it over. If you are interested to push it forward, then I'd suggest to open new GHC proposal.

Note: See TracTickets for help on using tickets.