module Monad:sig..end
Duppy.Io.
This module can be used to write code that runs in various Duppy's tasks and raise values in a completely transparent way.
You can see examples of its use
in the examples/ directory of the
source code and in the files
src/tools/{harbor.camlp4,server.camlp4}
in liquidsoap's code.
When a server communicates with a client, it performs several computations and, eventually, terminates. A computation can either return a new value or terminate. For instance:
type ('a, 'b) t
'a
or raises a value of type 'bval return : 'a -> ('a, 'b) treturn x create a computation that
returns value x.val raise : 'b -> ('a, 'b) traise x create a computation that raises
value x.val bind : ('a, 'b) t ->
('a -> ('c, 'b) t) -> ('c, 'b) tbind f g is equivalent to:
let x = f in g x where x
has f's return type.val (>>=) : ('a, 'b) t ->
('a -> ('c, 'b) t) -> ('c, 'b) t>>= is an alternative notation
for bindval run : return:('a -> unit) -> raise:('b -> unit) -> ('a, 'b) t -> unitrun f ~return ~raise () executes f and process
returned values with return or raised values
with raise.val catch : ('a, 'b) t ->
('b -> ('a, 'c) t) -> ('a, 'c) tcatch f g redirects values x raised during
f's execution to g. The name suggests the
usual try .. with .. exception catching.val (=<<) : ('b -> ('a, 'c) t) ->
('a, 'b) t -> ('a, 'c) t=<< is an alternative notation for catch.val fold_left : ('a -> 'b -> ('a, 'c) t) ->
'a -> 'b list -> ('a, 'c) tfold_left f a [b1; b2; ..] returns computation
(f a b1) >>= (fun a -> f a b2) >>= ...val iter : ('a -> (unit, 'b) t) -> 'a list -> (unit, 'b) titer f [x1; x2; ..] returns computation
f x1 >>= (fun () -> f x2) >>= ...module Mutex:sig..end
module Condition:sig..end
module Io:sig..end
Duppy.Io.