Module Bogue.Utils

module Utils: sig .. end

Utilities.

This module contains several utilities, in particular for debug logs.

Dependency graph

Debugging

val printd : int -> ('a, unit, string, unit) Stdlib.format4 -> 'a

For instance printd debug_warning "The value x=%u is too big" x will print a message in the console only if the Utils.debug variable contains the debug_warning flag.

val debug : bool Stdlib.ref
val debug_code : int Stdlib.ref

Logical ored of !debug with debug flags (below) controls the amount of debuging.

Binary masks (=flags) for debugging messages.

val debug_thread : int
val debug_warning : int
val debug_graphics : int
val debug_error : int
val debug_io : int
val debug_memory : int
val debug_board : int
val debug_event : int
val debug_custom : int

Maths

val pi : float
val round : float -> int

Round float to nearest integer.

val imax : int -> int -> int

imax a b returns max(a, b). (Same as Int.max).

val imin : int -> int -> int

imin a b returns min(a, b). (Same as Int.min).

Tsdl Result

val go : 'a Tsdl.Sdl.result -> 'a

Transform a result into a standard value, or fail with an error. Used for SDL functions only.

Options

Monadic style operations on optional variables.

val map_option : 'a option -> ('a -> 'b) -> 'b option

map_option o f is the same as Option.map f o.

val do_option : 'a option -> ('a -> unit) -> unit

do_option o f is the same as Option.iter f o.

val default : 'a option -> 'a -> 'a

default o v  is the same as Option.value o ~default:v. Warning: v is evaluated even if it is not used.

exception None_option
val remove_option : 'a option -> 'a

Like Option.get. Warning: remove_option None will raise the Utils.None_option exception.

Others

val let@ : ('a -> 'b) -> 'a -> 'b
val run : (unit -> 'a) -> 'a

run f is equivalent to f ().