package spotlib
Module Spotlib.Spot
include module type of struct include Base end
Common types
Result/Either monad using polymorphic variant. Obsolete. Use the primitive type result instead.
Function compositions and other operators
Functional composition. Haskell's (.) Use power if you want to use the original ( ** ).
Functional composition in swapped order. Same as Haskell's (>>>)
Super flip of Haskell. The first argument is labeled and becomes commutative.
Super flip of Haskell. The first argument is labeled and becomes commutative.
Imperative operations
val with_ref : 'a -> ('a ref -> 'b) -> 'a * 'bval with_ref_ : 'a -> ('a ref -> unit) -> 'awith_ref and with_ref_ runs a function with a reference with the specified initial value.
I/O
val with_oc : out_channel -> (out_channel -> 'a) -> 'aval with_ic : in_channel -> (in_channel -> 'a) -> 'aMisc things
val sprintf : ('a, unit, string) format -> 'aPrintf.sprintf is available without tying Printf.
val ksprintf : (string -> 'a) -> ('b, unit, string, 'a) format4 -> 'bPrintf.ksprintf is available without tying Printf.
val (!%) : ('a, unit, string) format -> 'aPrintf.sprintf, prefix style. Bought from ITPL.
val (!!%) : ('a, Format.formatter, unit) format -> 'aFormat.eprintf, prefix style.
val memoize_gen : (('a -> 'b) -> 'a -> 'b) -> ('a -> 'b) * ('a, 'b) Hashtbl.tGeneric memozation by hash with fixed point. You can call memoized self inside:
memoize_gen (fun self -> .... self v ....) f
Memozation by hash with fixed point. You can call memoized self inside:
memoize_rec (fun self -> .... self v ....) f
Simple profiling. Returns seconds. If f a raises an exception e, then time f a raises e too.
val (+=) : int ref -> int -> unitval (-=) : int ref -> int -> unitval find_by_iter :
(('a -> unit) -> 'collection -> unit) ->
('a -> bool) ->
'collection ->
'a optionfind the first element where predicate holds by iteration find_by_iter iterator predicate colleciton
find_in_tree get_subs p a visits a and finds the first sub node in which p holds. get_subs returns the sub nodes of a node.
Keep repeating a function until a final result is producted.
Comparison
compare_on f a b compares a and b not by themselves but by f a and f b.
val add_if_not_mem : 'a -> 'a list ref -> [> `AlreadyIn | `NewlyAdded ]add_if_not_mem adds a to asref if not (List.mem a !asref) then return `NewlyAdded. Otherwise it returns `AlreadIn and asref is not modified.
String <-> bytes conversions
module Monad = Monadmodule Option = Optioninclude module type of struct include Option.Pervasives end
val (//) : 'a Option.t -> 'a -> 'aSame as default but the default value is always evaluated
module Weaktbl = Weaktblmodule Hashset = Hashsetmodule File = Filemodule Comopt = Comoptmodule Overload = Overloadmodule Mtypes = Mtypesmodule Stream = SpotStreammodule Poly_result = Poly_resultmodule Result = Vresultinclude module type of struct include Result.Pervasives end
val ok : 'a -> ('a, 'error) resultval ng : 'error -> ('a, 'error) resultNo Good
val from_Ok : ('a, 'error) Vresult.t -> 'aRaises IsError when not Ok _
val result : ('a -> 'b) -> ('c -> 'b) -> ('a, 'c) Vresult.t -> 'bHaskell's either
val at_Error : ('err -> 'a) -> ('a, 'err) Vresult.t -> 'aat_Error = result id
module Tuple = Tupleinclude module type of struct include Tuple.Pervasives end
module Exn = Exninclude module type of struct include Exn.Pervasives end
Printf style errors
val failwithf : ('a, unit, string, 'b) format4 -> 'aval invalid_argf : ('a, unit, string, 'b) format4 -> 'aval raisef : (string -> exn) -> ('a, unit, string, 'b) format4 -> 'aException handling
It raises an exception Finally (org, final) when finally cannot recover the error.
It raises an exception Finally (org, final) when finally cannot recover the error.
val catch : ('a -> 'b) -> 'a -> ('b, [> `Exn of exn ]) resultval catch_ : (unit -> 'b) -> ('b, [> `Exn of exn ]) resulttee f v ~handler. If f v raises an exception e, handler e is executed, then e is reraised.
val with_return : ('a return -> 'a) -> 'amodule Temporal = Temporalmodule Year = Temporal.Yearmodule Date = Temporal.Datemodule Time = Temporal.Timemodule Datetime = Temporal.Datetimemodule List : sig ... endinclude module type of struct include Xlist.Pervasives end
val (+::=) : 'a list ref -> 'a -> unitSame as accum
module Array : sig ... endmodule Format : sig ... endmodule Hashtbl : sig ... endmodule String : sig ... endinclude module type of struct include Xstring.Pervasives end
module Bytes : sig ... endmodule Lazy : sig ... endmodule Filename : sig ... endinclude module type of struct include Xfilename.Pervasives end
module Filepath = Filepathmodule Unix : sig ... endinclude module type of struct include Xunix.Pervasives end
module Printf : sig ... endmodule Sys : sig ... endmodule Set = Xsetmodule StringSet : sig ... endmodule IntSet : sig ... endmodule Int64 : sig ... endmodule Printexc : sig ... endmodule Obj : sig ... endmodule URL = URLmodule Gc : sig ... endmodule UniqueID = UniqueIDmodule Once = Oncemodule Shell = Shellmodule Lexing : sig ... endmodule Command = Command