Ticket #1564 (new spam)

Opened 3 years ago

Last modified 2 years ago

C Bindings to Haskell Values

Reported by: aluink Owned by: aluink
Priority: OK Keywords: C bindings
Cc: Topic: Bindings
Difficulty: 1 person Summer Mentor: not-accepted

Description

Write an tool to convert Haskell values, structures and functions, to C bindings.

Overview

  • Convert Functions
  • Convert Data Structures
  • Typing
  • Documentation

Convert Functions

We need to find a way to convert Haskell functions, or pointers to, into C function pointers. This would allow many things to follow. Haskell class(HC) instances could have C Class(CC) definitions. So then calling the HC functions would be as simple as referring to the functions pointers stored in the CC. How to deal with general module functions is something to think about still. Something to also think about is how to convert the function pointers back to Haskell functions. This will be needed when passing function pointers to Haskell function calls. Do we want to allow the "lifting" of regular C functions into the pointers to Haskell functions so they can be passed to Haskell functions? This would almost seem required with such a system.

Convert Data Structures

Structures created with "data" will most likely be GObjects. Those done with "newtype" will most likely have to be duplicated, or maybe we can get away with #defines. If anything, we should probably be able to get away with a #define for "type" definitions. Some standard structures from the Prelude will have to be converted and included in the conversion tool.

Typing

Haskell has a, to put it lightly, strong typing system. We need to think about how to bring that into the C context. How much of it do we want to preserve?

Documentation

Any good tool is useless without documentation. Part of the deliverables of this project will be documentation on usage, how it works, and some man pages.

Change History

in reply to: ↑ description   Changed 3 years ago by aluink

This is not complete and is just high level ideas for now. Feel free to comment, share ideas, etc.

  Changed 2 years ago by dons

What is the relationship to e.g. c2hs?

  Changed 2 years ago by dons

  • priority changed from not yet rated to OK
Note: See TracTickets for help on using tickets.