@@ -5,11 +5,12 @@ import gleam/result
5
5
/// `Dynamic` data is data that we don"t know the type of yet.
6
6
/// We likely get data like this from interop with Erlang, or from
7
7
/// IO with the outside world.
8
- pub external type Dynamic ;
8
+ pub external type Dynamic
9
9
10
10
/// Convert any Gleam data into `Dynamic` data.
11
11
///
12
- pub external fn from(a) -> Dynamic = "gleam_stdlib" "identity";
12
+ pub external fn from ( a) -> Dynamic =
13
+ "gleam_stdlib" "identity"
13
14
14
15
/// Unsafely cast a Dynamic value into any other type.
15
16
///
@@ -18,7 +19,8 @@ pub external fn from(a) -> Dynamic = "gleam_stdlib" "identity";
18
19
///
19
20
/// If you can avoid using this function, do!
20
21
///
21
- pub external fn unsafe_coerce(Dynamic) -> a = "gleam_stdlib" "identity";
22
+ pub external fn unsafe_coerce ( Dynamic ) -> a =
23
+ "gleam_stdlib" "identity"
22
24
23
25
/// Check to see whether a Dynamic value is a string, and return the string if
24
26
/// it is.
@@ -31,8 +33,8 @@ pub external fn unsafe_coerce(Dynamic) -> a = "gleam_stdlib" "identity";
31
33
/// > string(from(123))
32
34
/// Error("Expected a String, got `123`")
33
35
///
34
- pub external fn string(from: Dynamic) -> Result(String, String)
35
- = "gleam_stdlib" "decode_string"
36
+ pub external fn string ( from : Dynamic ) -> Result ( String , String ) =
37
+ "gleam_stdlib" "decode_string"
36
38
37
39
/// Check to see whether a Dynamic value is an int, and return the int if it
38
40
/// is.
@@ -45,8 +47,8 @@ pub external fn string(from: Dynamic) -> Result(String, String)
45
47
/// > int(from("Hello"))
46
48
/// Error("Expected an Int, got `\"Hello World\"`")
47
49
///
48
- pub external fn int(from: Dynamic) -> Result(Int, String)
49
- = "gleam_stdlib" "decode_int"
50
+ pub external fn int ( from : Dynamic ) -> Result ( Int , String ) =
51
+ "gleam_stdlib" "decode_int"
50
52
51
53
/// Check to see whether a Dynamic value is an float, and return the float if
52
54
/// it is.
@@ -59,8 +61,8 @@ pub external fn int(from: Dynamic) -> Result(Int, String)
59
61
/// > float(from(123))
60
62
/// Error("Expected a Float, got `123`")
61
63
///
62
- pub external fn float(from: Dynamic) -> Result(Float, String)
63
- = "gleam_stdlib" "decode_float"
64
+ pub external fn float ( from : Dynamic ) -> Result ( Float , String ) =
65
+ "gleam_stdlib" "decode_float"
64
66
65
67
/// Check to see whether a Dynamic value is an atom, and return the atom if
66
68
/// it is.
@@ -74,8 +76,8 @@ pub external fn float(from: Dynamic) -> Result(Float, String)
74
76
/// > atom(from(123))
75
77
/// Error("Expected an Atom, got `123`")
76
78
///
77
- pub external fn atom(from: Dynamic) -> Result(atom.Atom, String)
78
- = "gleam_stdlib" "decode_atom"
79
+ pub external fn atom ( from : Dynamic ) -> Result ( atom . Atom , String ) =
80
+ "gleam_stdlib" "decode_atom"
79
81
80
82
/// Check to see whether a Dynamic value is an bool, and return the bool if
81
83
/// it is.
@@ -88,8 +90,8 @@ pub external fn atom(from: Dynamic) -> Result(atom.Atom, String)
88
90
/// > bool(from(123))
89
91
/// Error("Expected a Bool, got `123`")
90
92
///
91
- pub external fn bool(from: Dynamic) -> Result(Bool, String)
92
- = "gleam_stdlib" "decode_bool"
93
+ pub external fn bool ( from : Dynamic ) -> Result ( Bool , String ) =
94
+ "gleam_stdlib" "decode_bool"
93
95
94
96
/// Check to see whether a Dynamic value is a function that takes no arguments,
95
97
/// and return the function if it is.
@@ -104,11 +106,11 @@ pub external fn bool(from: Dynamic) -> Result(Bool, String)
104
106
/// > thunk(from(123))
105
107
/// Error("Expected a zero arity function, got `123`")
106
108
///
107
- pub external fn thunk(from: Dynamic) -> Result(fn() -> Dynamic, String)
108
- = "gleam_stdlib" "decode_thunk"
109
+ pub external fn thunk ( from : Dynamic ) -> Result ( fn ( ) -> Dynamic , String ) =
110
+ "gleam_stdlib" "decode_thunk"
109
111
110
- external fn list_dynamic(from: Dynamic) -> Result(List(Dynamic), String)
111
- = "gleam_stdlib" "decode_list"
112
+ external fn list_dynamic ( from : Dynamic ) -> Result ( List ( Dynamic ) , String ) =
113
+ "gleam_stdlib" "decode_list"
112
114
113
115
/// Check to see whether a Dynamic value is a list, and return the list if it
114
116
/// is.
@@ -130,7 +132,7 @@ pub fn list(
130
132
) -> Result ( List ( inner) , String ) {
131
133
dynamic
132
134
|> list_dynamic
133
- |> result.then(_, list_mod.traverse(_, decoder_type))
135
+ |> result . then ( list_mod . traverse ( _, decoder_type ) )
134
136
}
135
137
136
138
/// Check to see if a Dynamic value is a map with a specific field, and return
@@ -147,8 +149,8 @@ pub fn list(
147
149
/// > field(from(123), "Hello")
148
150
/// Error("Expected a map with key `\"Hello\"`, got an Int")
149
151
///
150
- pub external fn field(from: Dynamic, named: a) -> Result(Dynamic, String)
151
- = "gleam_stdlib" "decode_field"
152
+ pub external fn field ( from : Dynamic , named : a) -> Result ( Dynamic , String ) =
153
+ "gleam_stdlib" "decode_field"
152
154
153
155
/// Check to see if the Dynamic value is a tuple large enough to have a certain
154
156
/// index, and return the value of that index if it is.
@@ -164,5 +166,8 @@ pub external fn field(from: Dynamic, named: a) -> Result(Dynamic, String)
164
166
/// > element(from(""), 2)
165
167
/// Error("Expected a Tuple, got a binary")
166
168
///
167
- pub external fn element(from: Dynamic, position: Int) -> Result(Dynamic, String)
168
- = "gleam_stdlib" "decode_element"
169
+ pub external fn element (
170
+ from : Dynamic ,
171
+ position : Int ,
172
+ ) -> Result ( Dynamic , String ) =
173
+ "gleam_stdlib" "decode_element"
0 commit comments