From 01224f598818b261c83eda224dcae02e56e8a6ab Mon Sep 17 00:00:00 2001 From: NoahBatchelor Date: Fri, 19 Jul 2024 12:49:57 -0500 Subject: [PATCH] Formatting Formatting had to be done manually due to mismatching ocamlformat installations. --- src/core/CCOption.ml | 5 ++--- src/core/CCOption.mli | 6 +++--- src/core/CCResult.ml | 5 ++--- src/core/CCResult.mli | 9 ++++++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/core/CCOption.ml b/src/core/CCOption.ml index 3685ae6c..5a6b50a4 100644 --- a/src/core/CCOption.ml +++ b/src/core/CCOption.ml @@ -55,10 +55,9 @@ let[@inline] bind o f = flat_map f o let ( >>= ) = bind let pure x = Some x -let k_compose f g = - (fun x -> f x |> flat_map g) +let k_compose f g x = f x |> flat_map g let ( >=> ) = k_compose -let ( <=< ) f g = (>=>) g f +let ( <=< ) f g = g >=> f let ( <*> ) f x = match f, x with diff --git a/src/core/CCOption.mli b/src/core/CCOption.mli index b2ee3bb2..bc921ee6 100644 --- a/src/core/CCOption.mli +++ b/src/core/CCOption.mli @@ -58,7 +58,7 @@ val bind : 'a t -> ('a -> 'b t) -> 'b t Monadic bind. @since 3.0 *) -val k_compose : ('a -> 'b t) -> ('b -> 'c t) -> ('a -> 'c t) +val k_compose : ('a -> 'b t) -> ('b -> 'c t) -> 'a -> 'c t (** Kleisli composition. Monadic equivalent of CCFun.compose *) val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t @@ -192,10 +192,10 @@ module Infix : sig val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t val ( and* ) : 'a t -> 'b t -> ('a * 'b) t - val ( >=> ) : ('a -> 'b t) -> ('b -> 'c t) -> ('a -> 'c t) + val ( >=> ) : ('a -> 'b t) -> ('b -> 'c t) -> 'a -> 'c t (** Monadic [k_compose]. *) - val ( <=< ) : ('b -> 'c t) -> ('a -> 'b t) -> ('a -> 'c t) + val ( <=< ) : ('b -> 'c t) -> ('a -> 'b t) -> 'a -> 'c t (** Reverse monadic [k_compose]. *) end diff --git a/src/core/CCResult.ml b/src/core/CCResult.ml index 7ebc5220..1706951f 100644 --- a/src/core/CCResult.ml +++ b/src/core/CCResult.ml @@ -132,11 +132,10 @@ let flat_map f e = | Ok x -> f x | Error s -> Error s -let k_compose f g = - (fun x -> flat_map g @@ f x) +let k_compose f g x = f x |> flat_map g let ( >=> ) = k_compose -let ( <=< ) f g = ( >=> ) g f +let ( <=< ) f g = g >=> f let equal ~err eq a b = match a, b with diff --git a/src/core/CCResult.mli b/src/core/CCResult.mli index 16753a52..a5f7e6c0 100644 --- a/src/core/CCResult.mli +++ b/src/core/CCResult.mli @@ -120,7 +120,8 @@ val catch : ('a, 'err) t -> ok:('a -> 'b) -> err:('err -> 'b) -> 'b val flat_map : ('a -> ('b, 'err) t) -> ('a, 'err) t -> ('b, 'err) t -val k_compose : ('a -> ('b, 'err) t) -> ('b -> ('c, 'err) t) -> ('a -> ('c, 'err) t) +val k_compose : + ('a -> ('b, 'err) t) -> ('b -> ('c, 'err) t) -> 'a -> ('c, 'err) t (** Kleisli composition. Monadic equivalent of CCFun.compose *) val equal : err:'err equal -> 'a equal -> ('a, 'err) t equal @@ -212,10 +213,12 @@ module Infix : sig val ( and* ) : ('a, 'e) t -> ('b, 'e) t -> ('a * 'b, 'e) t (** @since 2.8 *) - val ( >=> ) : ('a -> ('b, 'err) t) -> ('b -> ('c, 'err) t) -> ('a -> ('c, 'err) t) + val ( >=> ) : + ('a -> ('b, 'err) t) -> ('b -> ('c, 'err) t) -> 'a -> ('c, 'err) t (** Monadic [k_compose]. *) - val ( <=< ) : ('b -> ('c, 'err) t) -> ('a -> ('b, 'err) t) -> ('a -> ('c, 'err) t) + val ( <=< ) : + ('b -> ('c, 'err) t) -> ('a -> ('b, 'err) t) -> 'a -> ('c, 'err) t (** Reverse monadic [k_compose]. *) end