package bogue

  1. Overview
  2. Docs

Module Bogue.UtilsSource

Utilities

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

Dependency graph

Debugging

Sourceval printd : int -> ('a, unit, string, unit) 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 debug variable contains the debug_warning flag.

Sourceval debug : bool ref
Sourceval debug_code : int ref

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

Binary masks (=flags) for debugging messages.

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

Maths

Sourceval pi : float
Sourceval round : float -> int

Round float to nearest integer.

Sourceval imax : int -> int -> int

imax a b returns max(a, b).

Sourceval imin : int -> int -> int

imin a b returns min(a, b).

Tsdl Result

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

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

Options

Monadic style operations on optional variables.

Sourceval map_option : 'a option -> ('a -> 'b) -> 'b option
Sourceval do_option : 'a option -> ('a -> unit) -> unit
Sourceval default : 'a option -> 'a -> 'a
Sourceexception None_option
Sourceval remove_option : 'a option -> 'a

Warning: remove_option None will raise the None_option exception.

Others

Sourceval run : (unit -> 'a) -> 'a

run f is equivalent to f ().