package inferno

  1. Overview
  2. Docs

Source file 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
29
30
31
32
33
34
35
36
37
38
39
40
(******************************************************************************)
(*                                                                            *)
(*                                  Inferno                                   *)
(*                                                                            *)
(*                       François Pottier, Inria Paris                        *)
(*                                                                            *)
(*  Copyright Inria. All rights reserved. This file is distributed under the  *)
(*  terms of the MIT License, as described in the file LICENSE.               *)
(*                                                                            *)
(******************************************************************************)

let iter f o =
  match o with
  | None ->
      ()
  | Some x ->
      f x

let fold f o accu =
  match o with
  | None ->
      accu
  | Some x ->
      f x accu

let map f o =
  match o with
  | None ->
      None
  | Some x ->
      Some (f x)

let multiply m o1 o2 =
  match o1, o2 with
  | None, o
  | o, None ->
      o
  | Some x1, Some x2 ->
      Some (m x1 x2)

OCaml

Innovation. Community. Security.