package kappa-library

  1. Overview
  2. Docs
Public internals of the Kappa tool suite. Use this package to use kappa as a lib

Install

Dune Dependency

Authors

Maintainers

Sources

v4.1.3.tar.gz
md5=1c9a8a0d79f085757817f90834e166f5
sha512=13ac40442940ba6e72d7dc5bf952e67443872f7bff63e9c76a3a699a6904c88696047fe04519b7ec6546371642f6ee7b0983117be302694aca15500b0df40de3

doc/src/kappa-library.generic/option_util.ml.html

Source file option_util.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
(******************************************************************************)
(*  _  __ * The Kappa Language                                                *)
(* | |/ / * Copyright 2010-2020 CNRS - Harvard Medical School - INRIA - IRIF  *)
(* | ' /  *********************************************************************)
(* | . \  * This file is distributed under the terms of the                   *)
(* |_|\_\ * GNU Lesser General Public License Version 3                       *)
(******************************************************************************)

let unsome default = function
  | None -> default
  | Some a -> a

let unsome_or_raise
    ?(excep = Invalid_argument "unsome_or_raise was passed a None") = function
  | None -> raise excep
  | Some a -> a

let map f = function
  | Some x -> Some (f x)
  | None -> None

let bind f = function
  | None -> None
  | Some o -> f o

let fold f x = function
  | None -> x
  | Some y -> f x y

let equal eq a b =
  match a, b with
  | None, None -> true
  | Some _, None | None, Some _ -> false
  | Some x, Some y -> eq x y
OCaml

Innovation. Community. Security.