package yocaml_unix

  1. Overview
  2. Docs
On This Page
  1. API
  2. Runtime

Module Yocaml_unixSource

A runtime describes the set of "low-level" primitives to operate in a specific context. This separation allows to have a pure and platform agnostic kernel (the Yocaml module) and to define specific runtimes as needed. Here is the runtime for UNIXish (OSX/Linux).

API

Sourceval execute : 'a Yocaml.Effect.t -> 'a

Executes a YOCaml program using the UNIX Runtime.

Sourceval serve : filepath:string -> port:int -> unit Yocaml.t -> unit Lwt.t

serve ~filepath ~port engine will serve, a bit like the sad python server, a static directory ... in addition, the function takes an OCaml program and re-executes it on every HTTP request that does not point to a 404. Very handy for continuous content development!

Runtime

Inclusion of the runtime to be able to use Yocaml_unix as runtime directly.

include Yocaml.Runtime.RUNTIME with type 'a t = 'a
Sourcetype 'a t = 'a
Sourceval bind : 'a t -> ('a -> 'b t) -> 'b t
Sourceval return : 'a -> 'a t
Sourceval get_time : unit -> float t

get_time () should returns a float like Unix.gettimeofday ().

Sourceval file_exists : Yocaml.Filepath.t -> bool t

file_exists path should returns true if path exists (as a file or a directory), false otherwise.

Sourceval target_exists : Yocaml.Filepath.t -> bool t

Same of file_exists but acting on the target.

Sourceval is_directory : Yocaml.Filepath.t -> bool t

is_directory path should returns true if path is an existing file and if the file is a directory, false otherwise.

Sourceval get_modification_time : Yocaml.Filepath.t -> int Yocaml.Try.t t

get_modification_time path should returns a Try.t containing the modification time (as an integer) of the given file. The function may fail.

Sourceval target_modification_time : Yocaml.Filepath.t -> int Yocaml.Try.t t

Same of get_modification_time but acting on the target.

Sourceval read_file : Yocaml.Filepath.t -> string Yocaml.Try.t t

read_file path should returns a Try.t containing the content (as a string) of the given file. The function may fail.

Sourceval content_changes : Yocaml.Filepath.t -> string -> bool Yocaml.Try.t t

content_changes filepath new_content check if the content of the file has been changed.

Sourceval write_file : Yocaml.Filepath.t -> string -> unit Yocaml.Try.t t

write_file path content should write (create or overwrite) content into the given path. The function may fail.

read_dir path should returns a list of children. The function is pretty optimistic if the directory does not exist, or for any other possible reason the function should fail, it will return an empty list.

Sourceval create_dir : ?file_perm:int -> Yocaml.Filepath.t -> unit t

create_dir path is an optimistic version of mkdir -p, the function extract the directory of a file and create it if it does not exists without any failure.

Sourceval log : Yocaml.Log.level -> string -> unit t

log level message justs dump a message on stdout.

Sourceval command : string -> int t

command cmd performs a shell commands and returns the exit code.