ocaml-dynatvar / dynvar.mli

(** Dynamically typed variables

WARNING!  It's not tested yet!

Author: Dmitry Grebeniuk - gdsfh1 at gmail dot com

Look at http://janestcapital.com/?q=node/18 too

(** Exception [Type_error (value_type, used_with_type)] is
    raised by [get] if you are trying to get the value of
    wrong type.
exception Type_error of (string * string)

(** Type of the value that represents the type of dynamic variable *)
type ty 'a;

(** Type of dynamic variable *)
type var;

(** [mktype typename] creates a value that represents the type of
    dynamic variables you can create.  (i.e. it's the witness
    of dynamic variable's type)
value mktype : string -> ty 'a

(** [var ty val] creates dynamic variable with type [ty]
    and value [val].  The success of this operation is guaranteed
    by OCaml's type system.
value var : ty 'a -> 'a -> var

(** [get ty var] gets the value of dynamic variable [var]
    which should be created by [var ty val] with the same [ty].
    (same == "physically equal").
    @raise Type_error when types differ.
value get : ty 'a -> var -> 'a

type res 'a 'b = [= `Ok of 'a | `Error of 'b ]

(** [get_res ty var] returns either [`Ok val] with value of
    [var], or [`Error (value_type, used_with_type)] on type error.
value get_res : ty 'a -> var -> res 'a (string * string)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.