module BatStd:sig
..end
val print_bool : bool -> unit
val prerr_bool : bool -> unit
val input_file : ?bin:bool -> string -> string
val output_file : filename:string -> text:string -> unit
val string_of_char : char -> string
val identity : 'a -> 'a
val unique : unit -> int
val dump : 'a -> string
val print : 'a -> unit
dump
.val finally : (unit -> unit) -> ('a -> 'b) -> 'a -> 'b
finally fend f x
calls f x
and then fend()
even if f x
raised
an exception.val args : unit -> string BatEnum.t
args ()
is given by the elements of Sys.argv
, minus the first element.
val exe : string
exe
is given by the first argument of Sys.argv
val (|>) : 'a -> ('a -> 'b) -> 'b
Function application. x |> f
is equivalent to f x
.
This operator is commonly used to write a function composition
by order of evaluation means rather than by inverse order.
For instance, g (f x)
means "apply f
to x
, then apply
g
to the result." In some circumstances, it may be more
understandable to write this as x |> f |> g
, or
"starting from x
, apply f
, then apply g
."
This operator may also be useful for composing sequences of
function calls without too many parenthesis.
val (<|) : ('a -> 'b) -> 'a -> 'b
f <| x
is equivalent to f x
.
This operators may be useful for composing sequences of
function calls without too many parenthesis.
val (|-) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
f |- g
is fun x -> g (f x)
.
This is also equivalent to applying |>
twice.val (-|) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b
f -| g
is fun x -> f (g x)
. Mathematically, this is
operator o.val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c
flip f x y
is f y x
. Don't abuse this function, it may shorten considerably
your code but it also has the nasty habit of making it harder to read.
val ( *** ) : ('a -> 'b) -> ('c -> 'd) -> 'a * 'c -> 'b * 'd
f *** g
is fun (x,y) -> (f x, g y)
.
val (&&&) : ('a -> 'b) -> ('a -> 'c) -> 'a -> 'b * 'c
f &&& g
is fun x -> (f x, g x)
.
val first : ('a -> 'b * 'c) -> 'a -> 'b
val second : ('a -> 'b * 'c) -> 'a -> 'c
val curry : ('a * 'b -> 'c) -> 'a -> 'b -> 'c
val uncurry : ('a -> 'b -> 'c) -> 'a * 'b -> 'c
val const : 'a -> 'b -> 'a
Therefore, const x
is the function which always returns x
.
type ('a, 'b)
result =
| |
Ok of |
|||
| |
Bad of |
(* | The result of a computation - either an Ok with the normal
result or a Bad with some value (often an exception) containing
failure information | *) |
val ignore_ok : ('a, exn) result -> unit
ignore_ok (f x)
ignores the result of f x
if it's ok, but
throws the exception contained if Bad
is returned.val ok : ('a, exn) result -> 'a
f x |> ok
unwraps the Ok
result of f x
and returns it, or
throws the exception contained if Bad
is returned.val wrap : ('a -> 'b) -> 'a -> ('b, exn) result
wrap f x
wraps a function that would normally throw an exception
on failure such that it now returns a result with either the Ok
return value or the Bad
exception.