diff --git a/core/CCFun.ml b/core/CCFun.ml index 849209bb..dbedcf9b 100644 --- a/core/CCFun.ml +++ b/core/CCFun.ml @@ -34,6 +34,10 @@ let flip f x y = f y x let curry f x y = f (x,y) +let id x = x + +let const x _ = x + let uncurry f (x,y) = f x y let (%>) = compose diff --git a/core/CCFun.mli b/core/CCFun.mli index 84381d62..d2a02f3e 100644 --- a/core/CCFun.mli +++ b/core/CCFun.mli @@ -35,6 +35,12 @@ val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c val (%>) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c (** Alias to [compose] *) +val id : 'a -> 'a +(** Identity function *) + +val const : 'a -> 'b -> 'a +(** [const x y = x] for any [y] *) + val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c (** flip arguments *)