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

Unbound type constructor Result.result #143

Open
thierry-FreeBSD opened this issue Apr 1, 2022 · 4 comments
Open

Unbound type constructor Result.result #143

thierry-FreeBSD opened this issue Apr 1, 2022 · 4 comments

Comments

@thierry-FreeBSD
Copy link

thierry-FreeBSD commented Apr 1, 2022

Trying to compile ppx_deriving_yojson v3.6.1 on FreeBSD, with OCaml 4.12.1 and dune 2.8.0 gives the following error:

File "src/ppx_deriving_yojson_runtime.mli", line 1, characters 32-45:
1 | type 'a error_or = ('a, string) Result.result
                                    ^^^^^^^^^^^^^
Error: Unbound type constructor Result.result

This simple patch fixes it:

--- src/ppx_deriving_yojson_runtime.mli.orig    2020-11-07 23:40:55 UTC
+++ src/ppx_deriving_yojson_runtime.mli
@@ -1,4 +1,4 @@
-type 'a error_or = ('a, string) Result.result
+type 'a error_or = ('a, string) Result.t
 
 val ( >>= ) : 'a error_or -> ('a -> 'b error_or) -> 'b error_or
 val ( >|= ) : 'a error_or -> ('a -> 'b) -> 'b error_or
@@ -18,7 +18,7 @@ module Int64 : (module type of Int64)
 module Nativeint : (module type of Nativeint)
 module Array : (module type of Array)
 module Result : sig
-  type ('a, 'b) result = ('a, 'b) Result.result =
+  type ('a, 'b) result = ('a, 'b) Result.t =
     | Ok of 'a
     | Error of 'b
 end
@mseri
Copy link
Collaborator

mseri commented Apr 1, 2022

Not to complain about your suggestion (I think it would be a good idea to get rid of result), however I believe that your error is due to a dune bug as in ocaml-ppx/ppx_deriving#257

@thierry-FreeBSD
Copy link
Author

Thanks, I was not aware of this bug!

@finalclass
Copy link

The bug got fixed in dune and I still experience it.

       The value `ty_to_yojson' is required but not provided

@finalclass
Copy link

finalclass commented Feb 11, 2024

Ok, I figured this out. The problem was that I assumend that "Result.result" comes from the "result" opam package while it was an internal module. This is the correct and full declaration that needs to go to the mli file:

val ty_of_yojson : Yojson.Safe.t -> (ty, string) Ppx_deriving_runtime.Result.result
val ty_to_yojson : ty -> Yojson.Safe.t

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

3 participants