ppx_deriving_yojson
ppx_deriving_yojson copied to clipboard
Unbound type constructor Result.result
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
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 https://github.com/ocaml-ppx/ppx_deriving/issues/257
Thanks, I was not aware of this bug!
The bug got fixed in dune and I still experience it.
The value `ty_to_yojson' is required but not provided
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