-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(bindings/haskell): init haskell binding #2463
Conversation
Signed-off-by: silver-ymz <[email protected]>
Signed-off-by: silver-ymz <[email protected]>
Signed-off-by: silver-ymz <[email protected]>
Signed-off-by: silver-ymz <[email protected]>
Signed-off-by: silver-ymz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM! This PR is good start! Are you willing to create a tracking issue of ongoing tasks? The first thing we should address is building the develop loop:
- Add contributing docs on how to setup the develop environment
- Add CI jobs on building and testing hs binding
And than we will need to implement more features, finally, we will handle the release process.
issue #2465 is opened for tracking. |
This is a demo for haskell binding.
Explanation
I researched 3 ways to complete haskell bindings.
The first way is the simplest way. However, the function of
hs-bindgen
is limited. Moreover,hs-bindgen
seems still a working experiment. I raised 2 issues about it which did not receive much attention from the author.yvan-sraka/hs-bindgen-attribute#2, https://github.com/yvan-sraka/reflexive/issues/1
As for the second way, using the existing C bindings can simplify the process of creating Haskell bindings. However, there are also some potential downsides.
For example, haskell can't deal with returned struct directly.
struct opendal_result_read opendal_operator_blocking_read(struct opendal_operator_ptr ptr, const char *path);
will be hard to use in haskell. We need to write some C codes to make it becomevoid opendal_operator_blocking_read(struct opendal_operator_ptr ptr, const char *path, struct opendal_result_read* result);
If we want some features about haskell binding, we must wait it in C bindings.
Because of these reasons, I choose to create a C-compatible interface from the Rust library.
Also ask advices from maintainers.
Example
Exported API will like this.
Tests
I write a simple test
testReadAndWriteToMemory
, which can pass now.