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). (Same as Int.max).

Sourceval imin : int -> int -> int

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

Tsdl Result

Sourceval 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.

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

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

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

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

Sourceval 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.

Sourceexception None_option
Sourceval remove_option : 'a option -> 'a

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

Others

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

run f is equivalent to f ().

OCaml

Innovation. Community. Security.