package alba
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4817038301d3e45bac9edf7e6f2fc8bf0a6d78e76e02ad7ea33ef69bcc17df3b
md5=25234357587126685d64f16236167937
doc/alba.fmlib/Fmlib/Io/module-type-SIG/index.html
Module type Io.SIG
Signature of an IO environment.
module M : Module_types.MONADinclude Module_types.MONAD
val return : 'a -> 'a treturn a makes a monadic container containing the value a.
m >>= f extracts the value a from the monadic container m and returns f a.
f >=> g composition of the two monadic functions f and g.
f >=> g is equivalent to fun a -> f a >>= g.
map f m maps the values in the monadic container m with the function f.
module Path : sig ... endmodule Process : sig ... endmodule Directory : sig ... endmodule File : sig ... endmodule Stdout : sig ... endWrite to standard output (usually the screen).
module Stderr : sig ... endWrite to standard error (usually the screen).
cli_loop state prompt next stop runs a cli loop which starts in state state and prompts its users with the string returned by prompt state. If prompt state returns None, the cli_loop is ended.
If the user enters a line, the command next state line is performed.
If prompt state returns None or the user ends its input by pressing ctrl-d, the command stop state is performed.
Example:
The following command starts a cli_loop and prompts the user at most 5 times with i> and echoes back the input of the user.
cli_loop
0
(fun i ->
if i < 5 then
Some (string_of_int i ^ "> ")
else
None)
(fun i line ->
Stdout.line line >>= fun _ -> return (i + 1))
(fun _ -> return ())