Skip to content
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

Nice caml API which avoids misuse #2

Open
Leonidas-from-XIV opened this issue Jul 4, 2018 · 3 comments
Open

Nice caml API which avoids misuse #2

Leonidas-from-XIV opened this issue Jul 4, 2018 · 3 comments

Comments

@Leonidas-from-XIV
Copy link
Contributor

I think there should be a nice public API which should make sure the user can't misuse the C API.

@ahem
Copy link
Contributor

ahem commented Jul 5, 2018

Yes! It should probably expose some sort of immutable API, and also the current code raises exceptions because the C-code became more clear that way. The API should probably catch those and use something like Or_error instead.

@Leonidas-from-XIV
Copy link
Contributor Author

Leonidas-from-XIV commented Jul 5, 2018

I agree with the exception part and yes, raising from C is probably way easier than all the stuff that is required to return an error monad from C.

I wouldn't pull in Or_error.t necessarily, instead opting for result with a polymorphic variant (result is a built-in type and while it does not have an corresponding utility module in the stdlib but every 3rd party stdlib like Containers, Batteries, Extlib, Base has a module to work with result). Then the jwt.ml would contain the OCaml C wrappers and would not be exposed to the caller, instead there would be a libjwt.ml with a high-level API.

I can look into this when I have time, unless you beat me to it 😄

@ahem
Copy link
Contributor

ahem commented Sep 27, 2018

Some of this was done with #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants