Skip to content

Commit 94ae609

Browse files
authored
Merge pull request #279 from anmonteiro/anmonteiro/drop-result
drop the `result` compatibility package dependency
2 parents 395911e + 970f1fd commit 94ae609

20 files changed

+41
-95
lines changed

ppx_deriving.opam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ depends: [
2020
"ocamlfind"
2121
"ppx_derivers"
2222
"ppxlib" {>= "0.32.0"}
23-
"result"
2423
"ounit2" {with-test}
2524
]
2625
synopsis: "Type-driven code generation for OCaml"

src/api/dune

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
(preprocess (pps ppxlib.metaquot))
66
(wrapped false)
77
(ppx_runtime_libraries ppx_deriving_runtime)
8-
(libraries
9-
compiler-libs.common
10-
ppxlib
11-
result
12-
ppx_derivers))
8+
(libraries compiler-libs.common ppxlib ppx_derivers))
139

1410
(rule
1511
(deps ppx_deriving.cppo.ml)

src/api/ppx_deriving.cppo.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,8 @@ let string_of_expression_opt (e : Parsetree.expression) : string option =
232232
| _ -> None
233233

234234
module Arg = struct
235-
type 'a conv = expression -> ('a, string) Result.result
235+
type 'a conv = expression -> ('a, string) result
236236

237-
open Result
238237
let expr expr = Ok expr
239238

240239
let int expr =

src/api/ppx_deriving.cppo.mli

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,37 +104,37 @@ module Arg : sig
104104
(** A type of conversion functions.
105105
106106
A conversion function of type ['a conv] converts a raw expression into an
107-
argument of type ['a]. Or returns [Result.Error "error"] if conversion
107+
argument of type ['a]. Or returns [Error "error"] if conversion
108108
fails. *)
109-
type 'a conv = expression -> ('a, string) Result.result
109+
type 'a conv = expression -> ('a, string) result
110110

111111
(** [expr] returns the input expression as-is. *)
112112
val expr : expression conv
113113

114114
(** [bool expr] extracts a boolean constant from [expr], or returns
115-
[Result.Error "boolean"] if [expr] does not contain a boolean literal. *)
115+
[Error "boolean"] if [expr] does not contain a boolean literal. *)
116116
val bool : bool conv
117117

118118
(** [int expr] extracts an integer constant from [expr], or returns
119-
[Result.Error "integer"] if [expr] does not contain an integer literal. *)
119+
[Error "integer"] if [expr] does not contain an integer literal. *)
120120
val int : int conv
121121

122122
(** [string expr] extracts a string constant from [expr], or returns
123-
[Result.Error "string"] if [expr] does not contain a string literal. *)
123+
[Error "string"] if [expr] does not contain a string literal. *)
124124
val string : string conv
125125

126126
(** [char expr] extracts a char constant from [expr], or returns
127-
[Result.Error "char"] if [expr] does not contain a char literal. *)
127+
[Error "char"] if [expr] does not contain a char literal. *)
128128
val char : char conv
129129

130130
(** [enum values expr] extracts a polymorphic variant constant from [expr],
131-
or returns [Result.Error "one of: `a, `b, ..."] if [expr] does not
131+
or returns [Error "one of: `a, `b, ..."] if [expr] does not
132132
contain a polymorphic variant constructor included in [values]. *)
133133
val enum : string list -> string conv
134134

135135
(** [list f expr] extracts a list constant from [expr] and maps every element
136-
through [f], or returns [Result.Error "list:..."] where [...] is the
137-
error returned by [f], or returns [Result.Error "list"] if [expr] does
136+
through [f], or returns [Error "list:..."] where [...] is the
137+
error returned by [f], or returns [Error "list"] if [expr] does
138138
not contain a list. *)
139139
val list : 'a conv -> 'a list conv
140140

src/runtime/dune

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
(name ppx_deriving_runtime)
33
(public_name ppx_deriving.runtime)
44
(wrapped false)
5-
(synopsis "Type-driven code generation")
6-
(libraries result))
5+
(synopsis "Type-driven code generation"))
76

87
(rule
98
(deps ppx_deriving_runtime.cppo.ml)

src/runtime/ppx_deriving_runtime.cppo.ml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ module Stdlib = Stdlib
2424

2525
include Stdlib
2626

27-
module Result = struct
28-
type ('a, 'b) t = ('a, 'b) result =
29-
| Ok of 'a
30-
| Error of 'b
31-
32-
type ('a, 'b) result = ('a, 'b) t =
33-
| Ok of 'a
34-
| Error of 'b
35-
end
3627
#else
3728
module Pervasives = Pervasives
3829
module Stdlib = Pervasives
@@ -58,18 +49,6 @@ module Weak = Weak
5849
module Printf = Printf
5950
module Format = Format
6051
module Buffer = Buffer
61-
module Result = struct
62-
(* the "result" compatibility module defines Result.result,
63-
not Result.t as the 4.08 stdlib *)
64-
type ('a, 'b) t = ('a, 'b) Result.result =
65-
| Ok of 'a
66-
| Error of 'b
67-
68-
(* ... and we also expose Result.result for backward-compatibility *)
69-
type ('a, 'b) result = ('a, 'b) Result.result =
70-
| Ok of 'a
71-
| Error of 'b
72-
end
7352
module Option = struct
7453
type 'a t = 'a option
7554

src/runtime/ppx_deriving_runtime.cppo.mli

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ include module type of struct
2828
end
2929

3030
module Stdlib = Stdlib
31-
32-
module Result : sig
33-
type ('a, 'b) t = ('a, 'b) result =
34-
| Ok of 'a
35-
| Error of 'b
36-
37-
(* we also expose Result.result for backward-compatibility
38-
with the Result package! *)
39-
type ('a, 'b) result = ('a, 'b) t =
40-
| Ok of 'a
41-
| Error of 'b
42-
end
4331
#else
4432
module Pervasives = Pervasives
4533

@@ -71,17 +59,6 @@ module Printf = Printf
7159
module Format = Format
7260
module Buffer = Buffer
7361

74-
module Result : sig
75-
type ('a, 'b) t = ('a, 'b) Result.result =
76-
| Ok of 'a
77-
| Error of 'b
78-
79-
(* we also expose Result.result for backward-compatibility *)
80-
type ('a, 'b) result = ('a, 'b) Result.result =
81-
| Ok of 'a
82-
| Error of 'b
83-
end
84-
8562
module Option : sig
8663
type 'a t = 'a option
8764

src_plugins/eq/ppx_deriving_eq.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ and expr_of_typ quoter typ =
9797
[%type: ([%t? ok_t], [%t? err_t]) Result.result]) ->
9898
[%expr fun x y ->
9999
match x, y with
100-
| Result.Ok a, Result.Ok b -> [%e expr_of_typ ok_t] a b
101-
| Result.Error a, Result.Error b -> [%e expr_of_typ err_t] a b
100+
| Ok a, Ok b -> [%e expr_of_typ ok_t] a b
101+
| Error a, Error b -> [%e expr_of_typ err_t] a b
102102
| _ -> false]
103103
| true, ([%type: [%t? typ] lazy_t] | [%type: [%t? typ] Lazy.t]) ->
104104
[%expr fun (lazy x) (lazy y) -> [%e expr_of_typ typ] x y]

src_plugins/fold/ppx_deriving_fold.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ let rec expr_of_typ typ =
4040
[%type: ([%t? ok_t], [%t? err_t]) Result.result]) ->
4141
[%expr
4242
fun acc -> function
43-
| Result.Ok ok -> [%e expr_of_typ ok_t] acc ok
44-
| Result.Error err -> [%e expr_of_typ err_t] acc err]
43+
| Ok ok -> [%e expr_of_typ ok_t] acc ok
44+
| Error err -> [%e expr_of_typ err_t] acc err]
4545
| _, { ptyp_desc = Ptyp_constr ({ txt = lid }, args) } ->
4646
app (Exp.ident (mknoloc (Ppx_deriving.mangle_lid (`Prefix deriver) lid)))
4747
(List.map expr_of_typ args)

src_plugins/iter/ppx_deriving_iter.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ let rec expr_of_typ typ =
3333
[%expr Ppx_deriving_runtime.Array.iter [%e expr_of_typ typ]]
3434
| true, [%type: [%t? typ] option] ->
3535
[%expr function None -> () | Some x -> [%e expr_of_typ typ] x]
36+
| true, [%type: ([%t? ok_t], [%t? err_t]) result]
3637
| true, [%type: ([%t? ok_t], [%t? err_t]) Result.result] ->
3738
[%expr
3839
function
39-
| Result.Ok ok -> ignore ([%e expr_of_typ ok_t] ok)
40-
| Result.Error err -> ignore ([%e expr_of_typ err_t] err)]
40+
| Ok ok -> ignore ([%e expr_of_typ ok_t] ok)
41+
| Error err -> ignore ([%e expr_of_typ err_t] err)]
4142
| _, { ptyp_desc = Ptyp_constr ({ txt = lid }, args) } ->
4243
app (Exp.ident (mknoloc (Ppx_deriving.mangle_lid (`Prefix deriver) lid)))
4344
(List.map expr_of_typ args)

0 commit comments

Comments
 (0)