fpath icon indicating copy to clipboard operation
fpath copied to clipboard

Question about of_string restricting result type to [`Msg]

Open andreypopp opened this issue 8 years ago • 2 comments

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.

andreypopp avatar Feb 06 '18 14:02 andreypopp

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.

dbuenzli avatar Feb 06 '18 14:02 dbuenzli

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

andreypopp avatar Feb 06 '18 19:02 andreypopp