Module Cpp.DSL

A set of operators and helpers to make the OCaml code look more like the resultant C++

Some operators to make streams and method calls look more like the resultant C++

include module type of struct include Exprs end
val method_call : expr -> identifier -> type_ list -> expr list -> expr

Call a method on object, wrapping it in parentheses if it is not a variable

val to_var : identifier -> expr
val literal_string : string -> expr

Turn an OCaml string into a quoted and escaped C++ string

val std_vector_init_expr : type_ -> expr list -> expr

Equivalent to std::vector<t>{e1,...,en}

val fun_call : identifier -> expr list -> expr
val templated_fun_call : identifier -> type_ list -> expr list -> expr
val quiet_NaN : expr

Helper for std::numeric_limits<double>::quiet_NaN()

val int_min : expr

Helper for std::numeric_limits<int>::min()

val static_cast : type_ -> expr -> expr
val (<<) : expr -> expr list -> expr

A pun for the C++ operator<<

val (.@!()) : expr -> identifier -> expr

Method call: Call a no-argument method

E.g. foo.bar()

val (.@?()) : expr -> (identifier * expr list) -> expr

Method call: Call the named method with args

E.g. foo.bar(A1,...An)

val (.@<>()) : expr -> (identifier * type_ list * expr list) -> expr

Method call: Call the named method with template types and args

E.g. foo.bar<T1,...,Tn>(A1,...An)

val (|::!) : type_ -> identifier -> expr

Static method call: Call the named method with no arguments.

E.g. Foo::bar()

val (|::?) : type_ -> (identifier * expr list) -> expr

Static method call: Call the named method with args

E.g. Foo::bar(A1,...An)

val (|::<>) : type_ -> (identifier * type_ list * expr list) -> expr

Static method call: Call the named method with template types and args

E.g. Foo::bar<T1,...,Tn>(A1,...An)

val (+) : expr -> expr -> expr

Pun for C++ operator+(a,b)

val (-) : expr -> expr -> expr

Pun for C++ operator-(a,b)

val (*) : expr -> expr -> expr

Pun for C++ operator*(a,b)

val (.:{}) : type_ -> expr -> expr
val (.:{;..}) : type_ -> expr array -> expr
include module type of struct include Stmts end
val block : stmt list -> stmt

Wrap the list of statements in a block if it isn't a singleton block already

val unblock : stmt list -> stmt list
val rethrow_located : stmt list -> stmt list

Set up the try/catch logic for throwing an exception with its location set to the Stan program location.

val fori : identifier -> expr -> expr -> stmt -> stmt
val if_block : expr -> stmt list -> stmt
val unused : identifier -> stmt list

Suppress warnings for a variable which may not be used.

val (:=) : identifier -> expr -> stmt

Shorthand for assignment