Skip to content

Commit 9a6a4fa

Browse files
authored
Merge pull request #178 from psafont/noext
CP-33121: remove stdext's monadic usage
2 parents 3771207 + fcce709 commit 9a6a4fa

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

networkd/dune

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
rpclib
3333
systemd
3434
threads
35-
xapi-stdext-monadic
3635
xapi-stdext-pervasives
3736
xapi-stdext-threads
3837
xapi-stdext-unix

networkd/network_server.ml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
open Network_utils
1616
open Network_interface
17-
open Xapi_stdext_monadic
1817

1918
module S = Network_interface.Interface_API (Idl.Exn.GenServer ())
2019

@@ -226,8 +225,8 @@ module Sriov = struct
226225
let make_vf_config dbg pci_address (vf_info : sriov_pci_t) =
227226
Debug.with_thread_associated dbg
228227
(fun () ->
229-
let vlan = Opt.map Int64.to_int vf_info.vlan
230-
and rate = Opt.map Int64.to_int vf_info.rate
228+
let vlan = Option.map Int64.to_int vf_info.vlan
229+
and rate = Option.map Int64.to_int vf_info.rate
231230
and pcibuspath = Xcp_pci.string_of_address pci_address in
232231
debug "Config VF with pci address: %s" pcibuspath ;
233232
match make_vf_conf_internal pcibuspath vf_info.mac vlan rate with
@@ -298,13 +297,15 @@ module Interface = struct
298297
Ip.flush_ip_addr name
299298
)
300299
| DHCP4 ->
301-
let open Xapi_stdext_monadic in
302300
let gateway =
303-
Opt.default []
304-
(Opt.map (fun n -> [`gateway n]) !config.gateway_interface)
301+
Option.fold ~none:[]
302+
~some:(fun n -> [`gateway n])
303+
!config.gateway_interface
305304
in
306305
let dns =
307-
Opt.default [] (Opt.map (fun n -> [`dns n]) !config.dns_interface)
306+
Option.fold ~none:[]
307+
~some:(fun n -> [`dns n])
308+
!config.dns_interface
308309
in
309310
let options = gateway @ dns in
310311
Dhclient.ensure_running name options
@@ -886,9 +887,7 @@ module Bridge = struct
886887
)
887888
in
888889
let old_igmp_snooping = Ovs.get_mcast_snooping_enable ~name in
889-
Xapi_stdext_monadic.Opt.iter
890-
(destroy_existing_vlan_ovs_bridge dbg name)
891-
vlan ;
890+
Option.iter (destroy_existing_vlan_ovs_bridge dbg name) vlan ;
892891
ignore
893892
(Ovs.create_bridge ?mac ~fail_mode ?external_id ?disable_in_band
894893
?igmp_snooping vlan vlan_bug_workaround name) ;
@@ -898,7 +897,7 @@ module Bridge = struct
898897
ignore (Brctl.create_bridge name) ;
899898
Brctl.set_forwarding_delay name 0 ;
900899
Sysfs.set_multicast_snooping name false ;
901-
Xapi_stdext_monadic.Opt.iter (Ip.set_mac name) mac ;
900+
Option.iter (Ip.set_mac name) mac ;
902901
match vlan with
903902
| None ->
904903
()

test/test_jsonrpc_client.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
*)
1414

1515
open Test_highlevel
16-
open Xapi_stdext_monadic.Either
1716

1817
let dir = Filename.concat "test" "jsonrpc_files"
1918

20-
let jsonrpc_printer : Rpc.t Test_printers.printer = Jsonrpc.to_string
19+
let pp_jsonrpc fmt rpc = Format.fprintf fmt "%s" (Jsonrpc.to_string rpc)
2120

2221
module Input_json_object = Generic.MakeStateless (struct
2322
module Io = struct
2423
type input_t = string
2524

26-
type output_t = (exn, Rpc.t) Xapi_stdext_monadic.Either.t
25+
type output_t = (Rpc.t, exn) result
2726

2827
let string_of_input_t = Test_printers.string
2928

30-
let string_of_output_t = Test_printers.(either exn jsonrpc_printer)
29+
let string_of_output_t =
30+
Fmt.(str "%a" Dump.(result ~ok:pp_jsonrpc ~error:exn))
3131
end
3232

3333
let good_call =
@@ -47,12 +47,12 @@ module Input_json_object = Generic.MakeStateless (struct
4747
5_000_000_000L
4848
in
4949
let rpc = Jsonrpc.of_string ~strict:false json in
50-
Right rpc
50+
Ok rpc
5151
with
5252
| End_of_file ->
53-
Left End_of_file
53+
Error End_of_file
5454
| _ ->
55-
Left Parse_error
55+
Error Parse_error
5656
in
5757
close_in fin ; response
5858

@@ -61,14 +61,14 @@ module Input_json_object = Generic.MakeStateless (struct
6161
[
6262
(* A file containing exactly one JSON object. *)
6363
(* It has got curly braces inside strings to make it interesting. *)
64-
("good_call.json", Right good_call)
64+
("good_call.json", Ok good_call)
6565
; (* A file containing a partial JSON object. *)
66-
("short_call.json", Left Parse_error)
66+
("short_call.json", Error Parse_error)
6767
; (* A file containing a JSON object, plus some more characters at the
6868
end. *)
69-
("good_call_plus.json", Right good_call)
69+
("good_call_plus.json", Ok good_call)
7070
; (* A file containing some invalid JSON object. *)
71-
("bad_call.json", Left Parse_error)
71+
("bad_call.json", Error Parse_error)
7272
]
7373
end)
7474

xapi-networkd.opam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ depends: [
2020
"systemd"
2121
"xapi-idl"
2222
"xapi-inventory"
23-
"xapi-stdext-monadic"
2423
"xapi-stdext-pervasives"
2524
"xapi-stdext-threads"
2625
"xapi-stdext-unix"

0 commit comments

Comments
 (0)