package yocaml_unix

  1. Overview
  2. Docs

Module Yocaml_unix.RuntimeSource

Rexports Runtime to be used outside of the package.

include Yocaml.Required.RUNTIME with type 'a t = 'a
Sourcetype runtime_error

Runtime errors can be defined by the runtime creator.

Sourcetype 'a t = 'a

Each command is wrapped in a value of type 'a t, making it possible to build runtimes wrapped in monads (for example, Git/Irmin, which are currently based on Lwt).

Sourceval runtime_error_to_string : runtime_error -> string

Converts a runtime error into a character string for diagnosis.

Sourceval bind : ('a -> 'b t) -> 'a t -> 'b t

the bind primitive for t.

Sourceval return : 'a -> 'a t

the return primitive for t.

Sourceval log : [ `App | `Error | `Warning | `Info | `Debug ] -> string -> unit t

log level message log a message with a given message.

Sourceval get_time : unit -> int t

get_time () returns the current timestamp.

Sourceval file_exists : on:[ `Source | `Target ] -> Yocaml.Path.t -> bool t

file_exists ~on:source -> path returns true if the file exists, false otherwise.

Sourceval read_file : on:[ `Source | `Target ] -> Yocaml.Path.t -> (string, runtime_error) result t

read_file ~on:source -> path returns the content of a file.

Sourceval get_mtime : on:[ `Source | `Target ] -> Yocaml.Path.t -> (int, runtime_error) result t

get_mtime ~on:source path returns the modification time of a file.

Sourceval hash_content : string -> string t

hash_content str hash a content.

Sourceval create_directory : on:[ `Source | `Target ] -> Yocaml.Path.t -> (unit, runtime_error) result t

create_directory ~on path create a directory.

Sourceval write_file : on:[ `Source | `Target ] -> Yocaml.Path.t -> string -> (unit, runtime_error) result t

write_file ~on:source path content write a file.

Sourceval is_directory : on:[ `Source | `Target ] -> Yocaml.Path.t -> bool t

is_directory ~on:source path returns true if the given path is a directory, false otherwise.

Sourceval read_dir : on:[ `Source | `Target ] -> Yocaml.Path.t -> (Yocaml.Path.fragment list, runtime_error) result t

read_dir ~on:source path returns a list of filename (fragment) of a given directory.

Sourceval exec : ?is_success:(int -> bool) -> string -> string list -> (string, runtime_error) result t

exec ?is_success prog ?args will executes prog ...args. When is_success is provided, it is called with the exit code to determine whether it indicates success or failure. Without is_success, success requires the process to return an exit code of 0.

printing on standard output is returned.

OCaml

Innovation. Community. Security.