Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
module M : Fmlib.Module_types.MONAD
include Fmlib.Module_types.MONAD
val return : 'a -> 'a t
return 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 ... end
module Process : sig ... end
module Directory : sig ... end
module File : sig ... end
module Stdout : sig ... end
Write to standard output (usually the screen).
module Stderr : sig ... end
Write 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 ())