CCOpt.get_exn

This commit is contained in:
Simon Cruanes 2014-06-26 15:37:07 +02:00
parent ac35980c8b
commit 4c408d1182
2 changed files with 8 additions and 0 deletions

View file

@ -90,6 +90,10 @@ let fold f acc o = match o with
| None -> acc
| Some x -> f acc x
let get_exn = function
| Some x -> x
| None -> invalid_arg "CCOpt.get_exn"
let sequence_l l =
let rec aux acc l = match l with
| [] -> Some (List.rev acc)

View file

@ -60,6 +60,10 @@ val iter : ('a -> unit) -> 'a t -> unit
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
(** Fold on 0 or 1 elements *)
val get_exn : 'a t -> 'a
(** Open the option, possibly failing if it is [None]
@raise Invalid_argument if the option is [None] *)
val sequence_l : 'a t list -> 'a list t
(** {2 Applicative} *)