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
)
let default b a =
let default ~default l =
lazy (
match a with
| lazy Nil -> Lazy.force b
| lazy a -> a
match l with
| lazy Nil -> Lazy.force default
| lazy l -> l
)
(*$=
@ -96,7 +96,7 @@ let default b a =
module Infix = struct
let (>|=) x f = map ~f x
let (>>=) x f = flat_map ~f x
let (<|>) = default
let (<|>) a b = default ~default:b a
end
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
(** Monadic flatten + map. *)
val default : 'a t -> 'a t -> 'a t
val default : default:'a t -> 'a t -> 'a t
(** Choice operator.
@since NEXT_RELEASE *)