feat(bindings/haskell): init haskell binding#2463
Merged
Xuanwo merged 5 commits intoapache:mainfrom Jun 15, 2023
silver-ymz:feat/haskell-binding
Merged
feat(bindings/haskell): init haskell binding#2463Xuanwo merged 5 commits intoapache:mainfrom silver-ymz:feat/haskell-binding
Xuanwo merged 5 commits intoapache:mainfrom
silver-ymz:feat/haskell-binding
Conversation
Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>
Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>
Xuanwo
reviewed
Jun 15, 2023
Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>
Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>
Xuanwo
reviewed
Jun 15, 2023
Signed-off-by: silver-ymz <yinmingzhuo@gmail.com>
Xuanwo
approved these changes
Jun 15, 2023
Member
Xuanwo
left a comment
There was a problem hiding this comment.
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.
Member
Author
|
issue #2465 is opened for tracking. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-bindgenis limited. Moreover,hs-bindgenseems 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.