Skip to content
Snippets Groups Projects
Commit 4f2f4ea4 authored by Thibault Martin's avatar Thibault Martin
Browse files

Merge branch 'feature/librairies/option-let-bindings' into 'master'

[Librairies] Let bindings for the Option module

See merge request frama-c/frama-c!4454
parents f36709d1 1d3f0995
No related branches found
No related tags found
No related merge requests found
(**************************************************************************)
(* *)
(* This file is part of Frama-C. *)
(* *)
(* Copyright (C) 2007-2023 *)
(* CEA (Commissariat à l'énergie atomique et aux énergies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
include Stdlib.Option
let zip l r = match l, r with Some l, Some r -> Some (l, r) | _ -> None
module Operators = struct
let ( let* ) m f = bind m f
let ( let+ ) m f = map f m
let ( and* ) l r = zip l r
let ( and+ ) l r = zip l r
end
(**************************************************************************)
(* *)
(* This file is part of Frama-C. *)
(* *)
(* Copyright (C) 2007-2023 *)
(* CEA (Commissariat à l'énergie atomique et aux énergies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
(* Adding let binding operators to the Option module. See
https://v2.ocaml.org/manual/bindingops.html for more information. *)
include module type of Stdlib.Option
val zip : 'a option -> 'b option -> ('a * 'b) option
module Operators : sig
val ( let* ) : 'a option -> ('a -> 'b option) -> 'b option
val ( let+ ) : 'a option -> ('a -> 'b) -> 'b option
val ( and* ) : 'a option -> 'b option -> ('a * 'b) option
val ( and+ ) : 'a option -> 'b option -> ('a * 'b) option
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment