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

Question about of_string restricting result type to [`Msg] #12

Open
andreypopp opened this issue Feb 6, 2018 · 2 comments
Open

Question about of_string restricting result type to [`Msg] #12

andreypopp opened this issue Feb 6, 2018 · 2 comments

Comments

@andreypopp
Copy link

I apologise if that's not the right place for this question but I wonder why Fpath.of_string restricts the type of its result:

val of_string : string -> (t, [`Msg of string]) Result.result

instead of

val of_string : string -> (t, [> `Msg of string]) Result.result

Because of that I have to use double coercion in my code where I have other variants in the error side of the result.

@dbuenzli
Copy link
Owner

dbuenzli commented Feb 6, 2018

I'm no longer sure exactly why. Some type error messages may be a bit less unwidely if you proceed that way but it might not be a good reason to do this and maybe this should be opened (I'm a bit unsure how much code that would break though).

Note that if you are using rresult you can use R.open_error_msg rather than coercions.

@andreypopp
Copy link
Author

Thanks for clarification and for suggestion to use R.open_error_msg!

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

No branches or pull requests

2 participants