Skip to content

Commit 762161e

Browse files
committed
Improve names
1 parent f986571 commit 762161e

File tree

4 files changed

+75
-56
lines changed

4 files changed

+75
-56
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- The deprecated items in the `dynamic` module have been removed.
66
- The `from` function in the `dynamic` module has been deprecated.
7-
- The `array`, `bit_array`, `bool`, `float`, `int`, `list`, `null`, `object`,
7+
- The `array`, `bit_array`, `bool`, `float`, `int`, `list`, `nil`, `properties`,
88
and `string` functions have been added to the `dynamic` module.
99
- The performance of various functions in the `list` module has been improved.
1010
- Fixed the implementation of `option.values` and `option.all` to be tail

src/gleam/dynamic.gleam

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import gleam/dict
99
/// into Gleam data with known types. You will likely mostly use the other
1010
/// module in your projects.
1111
///
12+
/// The exact runtime representation of dynamic values will depend on the
13+
/// compilation target used.
14+
///
1215
pub type Dynamic
1316

1417
/// Return a string indicating the type of the dynamic value.
@@ -32,31 +35,39 @@ pub fn classify(data: Dynamic) -> String
3235
pub fn from(a: anything) -> Dynamic
3336

3437
/// Create a dynamic value from a bool.
38+
///
3539
@external(erlang, "gleam_stdlib", "identity")
3640
@external(javascript, "../gleam_stdlib.mjs", "identity")
3741
pub fn bool(a: Bool) -> Dynamic
3842

3943
/// Create a dynamic value from a string.
44+
///
45+
/// On Erlang this will be a binary string rather than a character list.
46+
///
4047
@external(erlang, "gleam_stdlib", "identity")
4148
@external(javascript, "../gleam_stdlib.mjs", "identity")
4249
pub fn string(a: String) -> Dynamic
4350

4451
/// Create a dynamic value from a float.
52+
///
4553
@external(erlang, "gleam_stdlib", "identity")
4654
@external(javascript, "../gleam_stdlib.mjs", "identity")
4755
pub fn float(a: Float) -> Dynamic
4856

4957
/// Create a dynamic value from an int.
58+
///
5059
@external(erlang, "gleam_stdlib", "identity")
5160
@external(javascript, "../gleam_stdlib.mjs", "identity")
5261
pub fn int(a: Int) -> Dynamic
5362

5463
/// Create a dynamic value from a bit array.
64+
///
5565
@external(erlang, "gleam_stdlib", "identity")
5666
@external(javascript, "../gleam_stdlib.mjs", "identity")
5767
pub fn bit_array(a: BitArray) -> Dynamic
5868

5969
/// Create a dynamic value from a list.
70+
///
6071
@external(erlang, "gleam_stdlib", "identity")
6172
@external(javascript, "../gleam_stdlib.mjs", "identity")
6273
pub fn list(a: List(Dynamic)) -> Dynamic
@@ -72,12 +83,19 @@ pub fn array(a: List(Dynamic)) -> Dynamic
7283

7384
/// Create a dynamic value made an unordered series of keys and values, where
7485
/// the keys are unique.
75-
pub fn object(entries: List(#(Dynamic, Dynamic))) -> Dynamic {
86+
///
87+
/// On Erlang this will be a map, on JavaScript this wil be a Gleam dict object.
88+
///
89+
pub fn properties(entries: List(#(Dynamic, Dynamic))) -> Dynamic {
7690
cast(dict.from_list(entries))
7791
}
7892

7993
/// A dynamic value representing nothing.
80-
pub fn null() -> Dynamic {
94+
///
95+
/// On Erlang this will be the atom `nil`, on JavaScript this wil be
96+
/// `undefined`.
97+
///
98+
pub fn nil() -> Dynamic {
8199
cast(Nil)
82100
}
83101

0 commit comments

Comments
 (0)