To focus the search input from anywhere on the page, press the 'S' key.
in-package search v0.1.0
-
travesty
-
-
travesty_containers
-
-
travesty_core_kernel_exts
Library
Module
Module type
Parameter
Class
Class type
Function combinator extensions for Core_kernel
.
This just re-exports Travesty_base_exts.Alist, but may contain Core_kernel
-specific extensions in future.
include module type of Travesty_base_exts.Fn
Constant predicates
These are convenience shorthands for Base.Fn.const
.
Pointwise liftings of operators
These complement Base.Fn.non
.
conj f g
lifts &&
over predicates f
and g
. It is short-circuiting: g
is never called if f
returns false.
Examples:
let is_zero = Int.(conj is_non_negative is_non_positive)
(* Short-circuiting: *)
conj always (fun () -> failwith "oops") (); (* --> exception *)
conj never (fun () -> failwith "oops") (); (* --> false *)
disj f g
lifts ||
over predicates f
and g
. It is short-circuiting: g
is never called if f
returns true.
Examples:
let is_not_zero = Int.(disj is_negative is_positive)
(* Short-circuiting: *)
disj never (fun () -> failwith "oops") (); (* --> exception *)
disj always (fun () -> failwith "oops") (); (* --> false *)
Miscellaneous combinators
on lift x y ~f
lifts a binary function f
using the lifter lift
. It does the same thing as the `on` function from Haskell, but with arguments flipped to make sense without infixing.
Effectively, it's Base.Comparable.lift
, but with a slightly different signature.
Example:
let ints = on fst ~f:Int.equal (42, "banana") (42, "apple") in
let strs = on snd ~f:String.equal (42, "banana") (42, "apple") in
ints, strs (* --> true, false *)