package alba
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=062f33c55ef39706c4290dff67d5a00bf009051fd757f9352be527f629ae21fc
md5=eb4edc4d6b7e15b83d6397bd34994153
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 ())