gleamgen/expression
Types
pub opaque type Expression(type_)
See math_operator
and math_operator_float
pub type MathOperator {
Add
Sub
Mul
Div
GreaterThan
GreaterThanOrEqual
LessThan
LessThanOrEqual
}
Constructors
-
Add
-
Sub
-
Mul
-
Div
-
GreaterThan
-
GreaterThanOrEqual
-
LessThan
-
LessThanOrEqual
Functions
pub fn call0(func: Expression(fn() -> a)) -> Expression(a)
Call a function or constructor with no arguments
expression.call0(
import_.function0(dict_module, dict.new)
)
|> expression.render(render.default_context())
|> render.to_string()
// -> "dict.new()"
pub fn call1(
func: Expression(fn(a) -> b),
arg1: Expression(a),
) -> Expression(b)
Call a function or constructor with one argument
See call0
pub fn call2(
func: Expression(fn(a, b) -> c),
arg1: Expression(a),
arg2: Expression(b),
) -> Expression(c)
Call a function or constructor with two arguments
See call0
pub fn call3(
func: Expression(fn(a, b, c) -> d),
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
) -> Expression(d)
Call a function or constructor with three arguments
See call0
pub fn call4(
func: Expression(fn(a, b, c, d) -> e),
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
) -> Expression(e)
Call a function or constructor with four arguments
See call0
pub fn call5(
func: Expression(fn(a, b, c, d, e) -> f),
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
) -> Expression(f)
Call a function or constructor with five arguments
See call0
pub fn call6(
func: Expression(fn(a, b, c, d, e, f) -> g),
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
arg6: Expression(f),
) -> Expression(g)
Call a function or constructor with six arguments
See call0
pub fn call7(
func: Expression(fn(a, b, c, d, e, f, g) -> h),
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
arg6: Expression(f),
arg7: Expression(g),
) -> Expression(h)
Call a function or constructor with seven arguments
See call0
pub fn call8(
func: Expression(fn(a, b, c, d, e, f, g, h) -> i),
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
arg6: Expression(f),
arg7: Expression(g),
arg8: Expression(h),
) -> Expression(i)
Call a function or constructor with eight arguments
See call0
pub fn call9(
func: Expression(fn(a, b, c, d, e, f, g, h, i) -> j),
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
arg6: Expression(f),
arg7: Expression(g),
arg8: Expression(h),
arg9: Expression(i),
) -> Expression(j)
Call a function or constructor with nine arguments
See call0
pub fn call_unchecked(
func: Expression(Unchecked),
args: List(Expression(Unchecked)),
) -> Expression(Unchecked)
Call a function or constructor without type checking
pub fn concat_string(
expr1: Expression(String),
expr2: Expression(String),
) -> Expression(String)
Use the <> operator to concatenate two strings
expression.concat_string(expression.string("hello "), expression.string("world"))
|> expression.render(render.default_context())
|> render.to_string()
// -> "\"hello \" <> \"world\""
pub fn math_operator(
expr1: Expression(Int),
op: MathOperator,
expr2: Expression(Int),
) -> Expression(Int)
Apply a math operator to two expressions with the type of Int
expression.math_operator(expression.int(3), expression.Add, expression.int(5))
|> expression.render(render.default_context())
|> render.to_string()
// -> "3 + 5"
pub fn math_operator_float(
expr1: Expression(Float),
op: MathOperator,
expr2: Expression(Float),
) -> Expression(Int)
Apply a math operator to two expressions with the type of Float
expression.math_operator_float(
expression.float(3.3),
expression.GreaterThan,
expression.unchecked_ident("other_float")
)
|> expression.render(render.default_context())
|> render.to_string()
// -> "3 >. other_float"
pub fn panic_(as_string: Option(String)) -> Expression(a)
Create a panic expression with an optional as clause
expression.todo_(option.Some("ahhhhhh!!!"))
|> expression.render(render.default_context())
|> render.to_string()
// -> "panic as \"ahhhhhh!!!\""
pub fn render_statement(
statement: Statement,
context: Context,
) -> Rendered
pub fn to_unchecked(
type_: Expression(a),
) -> Expression(Unchecked)
pub fn todo_(as_string: Option(String)) -> Expression(a)
Create a todo expression with an optional as clause
expression.todo_(option.Some("some unimplemented thing"))
|> expression.render(render.default_context())
|> render.to_string()
// -> "todo as \"some unimplemented thing\""
pub fn tuple3(
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
) -> Expression(#(a, b, c))
pub fn tuple4(
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
) -> Expression(#(a, b, c, d))
pub fn tuple5(
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
) -> Expression(#(a, b, c, d, e))
pub fn tuple6(
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
arg6: Expression(f),
) -> Expression(#(a, b, c, d, e, f))
pub fn tuple7(
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
arg6: Expression(f),
arg7: Expression(g),
) -> Expression(#(a, b, c, d, e, f, g))
pub fn tuple8(
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
arg6: Expression(f),
arg7: Expression(g),
arg8: Expression(h),
) -> Expression(#(a, b, c, d, e, f, g, h))
pub fn tuple9(
arg1: Expression(a),
arg2: Expression(b),
arg3: Expression(c),
arg4: Expression(d),
arg5: Expression(e),
arg6: Expression(f),
arg7: Expression(g),
arg8: Expression(h),
arg9: Expression(i),
) -> Expression(#(a, b, c, d, e, f, g, h, i))
pub fn type_(expr: Expression(a)) -> GeneratedType(a)
Get the internal type of an expression
pub fn unchecked_ident(value: String) -> Expression(a)
Provide an ident that could be of any type
pub fn unsafe_from_unchecked(
type_: Expression(a),
) -> Expression(b)
Convert an expression to any type without checking