gleam/dynamic
Types
Dynamic
data is data that we don’t know the type of yet.
We likely get data like this from interop with Erlang, or from
IO with the outside world.
This module contains code for forming dynamic data, and the
gleam/dynamic/decode
module contains code for turning dynamic data back
into Gleam data with known types. You will likely mostly use the other
module in your projects.
The exact runtime representation of dynamic values will depend on the compilation target used.
pub type Dynamic
Values
pub fn array(a: List(Dynamic)) -> Dynamic
Create a dynamic value from a list, converting it to a sequential runtime format rather than the regular list format.
On Erlang this will be a tuple, on JavaScript this wil be an array.
pub fn classify(data: Dynamic) -> String
Return a string indicating the type of the dynamic value.
This function may be useful for constructing error messages or logs. If you
want to turn dynamic data into well typed data then you want the
gleam/dynamic/decode
module.
classify(from("Hello"))
// -> "String"
pub fn from(a: anything) -> Dynamic
Deprecated: Please use the other functions in the gleam/dynamic module
pub fn nil() -> Dynamic
A dynamic value representing nothing.
On Erlang this will be the atom nil
, on JavaScript this wil be
undefined
.