diff --git a/src/iter/CCLazy_list.ml b/src/iter/CCLazy_list.ml index 3fc011ea..40a416d9 100644 --- a/src/iter/CCLazy_list.ml +++ b/src/iter/CCLazy_list.ml @@ -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 diff --git a/src/iter/CCLazy_list.mli b/src/iter/CCLazy_list.mli index 06983522..5f850518 100644 --- a/src/iter/CCLazy_list.mli +++ b/src/iter/CCLazy_list.mli @@ -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 *)