Internal utility functions that are commonly needed in many
places. Within Biocaml, all modules start with "open
Core.Std". When needed, we can also open this module to get some
extra functions, but it should not be opened unless it is
specifically needed.
module Biocaml_internal_utils:
sig
module Line:module type of Biocaml_line
with type t = Biocaml_line.t
module Pos:module type of Biocaml_pos
with type t = Biocaml_pos.t
module Stream: module type of CFStream_stream
val (|?) : 'a option -> 'a -> 'a
module Array:
sig
include Core.Std.Array
val range : 'a t -> int Biocaml_internal_utils.Stream.t
range xs
is the stream of all valid indices in xs
end
module Result:
sig
include Core.Std.Result
end
val try_finally_exn : fend:('a -> unit) -> ('a -> 'b) -> 'a -> 'b
try_finally_exn fend f a
will run x = f a
, then run fend
a
, and finally return x
. If f a
raised an exception that
exception will be returned even if f x
raises an exception too. If
f a
successfully produces x
, then it is possible to get instead
an exception raised by fend a
.val open_out_safe : string -> Pervasives.out_channel
open_out
but will not overwrite existing file.Operations on URL-style encodings.
module Url:
sig
val escape : string -> string
"%HX"
URL-escaping format.val unescape : string ->
error:(string -> 'error) -> (string, 'error) Biocaml_internal_utils.Result.t
"%HX"
escaped characters to a normal
string. In case of error, the string is passed to the ~error
parameter
and the function returns its result.end
module Debug:
sig
val enable : string -> unit
val disable : string -> unit
val make : string -> ('a, unit, string, unit) Pervasives.format4 -> 'a
end
val compare_of_list : ?equal:('a -> 'a -> bool) -> 'a list -> 'a -> 'a -> int
compare_of_list l
returns a comparison function that defines a
< b
if a
comes before b
in l
. The returned function will
raise an exception if it is applied to any element not in l
.end