default uses labelled argument

This commit is contained in:
Nicola Mometto 2018-03-06 15:37:57 +00:00 committed by Simon Cruanes
parent 68ad3d7408
commit 8f4c1a24b7
2 changed files with 6 additions and 6 deletions

View file

@ -82,11 +82,11 @@ let rec flat_map ~f l =
Lazy.force res Lazy.force res
) )
let default b a = let default ~default l =
lazy ( lazy (
match a with match l with
| lazy Nil -> Lazy.force b | lazy Nil -> Lazy.force default
| lazy a -> a | lazy l -> l
) )
(*$= (*$=
@ -96,7 +96,7 @@ let default b a =
module Infix = struct module Infix = struct
let (>|=) x f = map ~f x let (>|=) x f = map ~f x
let (>>=) x f = flat_map ~f x let (>>=) x f = flat_map ~f x
let (<|>) = default let (<|>) a b = default ~default:b a
end end
include Infix include Infix

View file

@ -45,7 +45,7 @@ val append : 'a t -> 'a t -> 'a t
val flat_map : f:('a -> 'b t) -> 'a t -> 'b t val flat_map : f:('a -> 'b t) -> 'a t -> 'b t
(** Monadic flatten + map. *) (** Monadic flatten + map. *)
val default : 'a t -> 'a t -> 'a t val default : default:'a t -> 'a t -> 'a t
(** Choice operator. (** Choice operator.
@since NEXT_RELEASE *) @since NEXT_RELEASE *)