Skip to content

Commit f0b6811

Browse files
committed
New dynamic API
1 parent e6bd140 commit f0b6811

File tree

4 files changed

+171
-130
lines changed

4 files changed

+171
-130
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
- The deprecated items in the `dynamic` module have been removed.
6+
- The `from` function in the `dynamic` module has been deprecated.
7+
- The `array`, `bit_array`, `bool`, `float`, `int`, `list`, `null`, `object`,
8+
and `string` functions have been added to the `dynamic` module.
59
- The performance of various functions in the `list` module has been improved.
610
- Fixed the implementation of `option.values` and `option.all` to be tail
711
recursive.

src/gleam/dynamic.gleam

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,51 +31,52 @@ pub fn classify(data: Dynamic) -> String
3131
@external(javascript, "../gleam_stdlib.mjs", "identity")
3232
pub fn from(a: anything) -> Dynamic
3333

34-
// TODO: document
34+
/// Create a dynamic value from a bool.
3535
@external(erlang, "gleam_stdlib", "identity")
3636
@external(javascript, "../gleam_stdlib.mjs", "identity")
3737
pub fn bool(a: Bool) -> Dynamic
3838

39-
// TODO: document
39+
/// Create a dynamic value from a string.
4040
@external(erlang, "gleam_stdlib", "identity")
4141
@external(javascript, "../gleam_stdlib.mjs", "identity")
4242
pub fn string(a: String) -> Dynamic
4343

44-
// TODO: document
45-
// TODO: test
44+
/// Create a dynamic value from a float.
4645
@external(erlang, "gleam_stdlib", "identity")
4746
@external(javascript, "../gleam_stdlib.mjs", "identity")
4847
pub fn float(a: Float) -> Dynamic
4948

50-
// TODO: document
49+
/// Create a dynamic value from an int.
5150
@external(erlang, "gleam_stdlib", "identity")
5251
@external(javascript, "../gleam_stdlib.mjs", "identity")
5352
pub fn int(a: Int) -> Dynamic
5453

55-
// TODO: document
56-
// TODO: test
54+
/// Create a dynamic value from a bit array.
5755
@external(erlang, "gleam_stdlib", "identity")
5856
@external(javascript, "../gleam_stdlib.mjs", "identity")
5957
pub fn bit_array(a: BitArray) -> Dynamic
6058

61-
// TODO: document
62-
// TODO: test
59+
/// Create a dynamic value from a list.
6360
@external(erlang, "gleam_stdlib", "identity")
6461
@external(javascript, "../gleam_stdlib.mjs", "identity")
6562
pub fn list(a: List(Dynamic)) -> Dynamic
6663

67-
// TODO: document
68-
// TODO: test
64+
/// Create a dynamic value from a list, converting it to a sequential runtime
65+
/// format rather than the regular list format.
66+
///
67+
/// On Erlang this will be a tuple, on JavaScript this wil be an array.
68+
///
6969
@external(erlang, "erlang", "list_to_tuple")
7070
@external(javascript, "../gleam_stdlib.mjs", "list_to_array")
7171
pub fn array(a: List(Dynamic)) -> Dynamic
7272

73-
// TODO: document
73+
/// Create a dynamic value made an unordered series of keys and values, where
74+
/// the keys are unique.
7475
pub fn object(entries: List(#(Dynamic, Dynamic))) -> Dynamic {
7576
cast(dict.from_list(entries))
7677
}
7778

78-
// TODO: document
79+
/// A dynamic value representing nothing.
7980
pub fn null() -> Dynamic {
8081
cast(Nil)
8182
}

0 commit comments

Comments
 (0)