package traits

  1. Overview
  2. Docs

Source file type_option.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(** Standard traits implementations for [option]

    It includes Stdlib's [Option] to be able to [open Traits] without losing
    access to [Option] *)

include Stdlib.Option

module PartialEq (T : Partial_eq.T) = struct
  module PartialEq = Partial_eq.Make (struct
    type t = T.PartialEq.t option
    type rhs = T.PartialEq.rhs option

    let eq x y =
      match (x, y) with
      | Some x, Some y -> Partial_eq.eq (module T) x y
      | _ -> false
  end)
end

module PartialEqSome (T : Partial_eq.T) = struct
  module PartialEq = Partial_eq.Make (struct
    type t = T.PartialEq.t
    type rhs = T.PartialEq.rhs option

    let eq x y =
      match y with Some y -> Partial_eq.eq (module T) x y | _ -> false
  end)
end
OCaml

Innovation. Community. Security.