aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2022-01-01 21:12:53 +0000
committerLouis Pilfold <louis@lpil.uk>2022-01-01 21:12:53 +0000
commit665e851b0d2a2fd249ac61911b6de4e2591971f9 (patch)
tree94502b2019d27eaa6502511378bf83aa6bcaee2d
parentcc5f01d6f2c0d62c17346e535cc5c1302127d903 (diff)
downloadgleam_stdlib-665e851b0d2a2fd249ac61911b6de4e2591971f9.tar.gz
gleam_stdlib-665e851b0d2a2fd249ac61911b6de4e2591971f9.zip
dynamic dynamic
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/gleam/dynamic.gleam10
2 files changed, 11 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 469aede..d186c98 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## Unreleased
+- The `dynamic` module gains the `dynamic` function.
- The `dynamic.list` function has been renamed to `dynamic.shallow_list`.
- The `dynamic.typed_list` function has been renamed to `dynamic.list`.
- The `dynamic.result` function has been removed.
diff --git a/src/gleam/dynamic.gleam b/src/gleam/dynamic.gleam
index 1d8e9ff..30a297c 100644
--- a/src/gleam/dynamic.gleam
+++ b/src/gleam/dynamic.gleam
@@ -58,6 +58,16 @@ if javascript {
"../gleam_stdlib.mjs" "identity"
}
+/// Converts a `Dynamic` value into a `Dynamic` value.
+///
+/// This function doesn't seem very useful at first, but it can be convenient
+/// when you need to give a decoder function but you don't actually care what
+/// the to-decode value is.
+///
+pub fn dynamic(term: Dynamic) -> Dynamic {
+ unsafe_coerce(term)
+}
+
/// Checks to see whether a `Dynamic` value is a bit_string, and returns that bit string if
/// it is.
///