@@ -14,12 +14,12 @@ pub type RemoteData(a, error) {
14
14
///
15
15
/// ## Examples
16
16
/// ```gleam
17
- /// map(over: Success(42 ), with: fn(x) { x * 2 } )
18
- /// // -> Success(84 )
17
+ /// map(over: Success(1 ), with: int.to_string )
18
+ /// // -> Success("1" )
19
19
/// ```
20
20
///
21
21
/// ```gleam
22
- /// map(over: Failure("error"), with: fn(x) { x * 2 } )
22
+ /// map(over: Failure("error"), with: int.to_string )
23
23
/// // -> Failure("error")
24
24
/// ```
25
25
pub fn map (
@@ -38,8 +38,8 @@ pub fn map(
38
38
///
39
39
/// ## Examples
40
40
/// ```gleam
41
- /// map_2(over: Success(42 ), over_2: Success(2), with: fn(a, b) { a + b })
42
- /// // -> Success(44 )
41
+ /// map_2(over: Success(1 ), over_2: Success(2), with: fn(a, b) { a + b })
42
+ /// // -> Success(3 )
43
43
/// ```
44
44
///
45
45
/// ```gleam
@@ -104,8 +104,8 @@ pub fn map_error(
104
104
///
105
105
/// ## Examples
106
106
/// ```gleam
107
- /// try(over: Success(42 ), with: fn(x) { Success(x * 2) })
108
- /// // -> Success(84 )
107
+ /// try(over: Success(1 ), with: fn(x) { Success(x * 2) })
108
+ /// // -> Success(2 )
109
109
/// ```
110
110
///
111
111
/// ```gleam
@@ -114,7 +114,7 @@ pub fn map_error(
114
114
/// ```
115
115
///
116
116
/// ```gleam
117
- /// try(over: Success(42 ), with: fn(x) { Failure("error") })
117
+ /// try(over: Success(1 ), with: fn(x) { Failure("error") })
118
118
/// // -> Failure("error")
119
119
/// ```
120
120
pub fn try (
@@ -132,12 +132,12 @@ pub fn try(
132
132
/// Unwrap a RemoteData, providing a default value if the data is not Success
133
133
/// ## Examples
134
134
/// ```gleam
135
- /// unwrap(data: Success(42 ), or: 0)
136
- /// // -> 42
135
+ /// unwrap(Success(1 ), or: 0)
136
+ /// // -> 1
137
137
/// ```
138
138
///
139
139
/// ```gleam
140
- /// unwrap(data: Failure("error"), or: 0)
140
+ /// unwrap(Failure("error"), or: 0)
141
141
/// // -> 0
142
142
/// ```
143
143
pub fn unwrap ( data : RemoteData ( a, error) , or default : a) -> a {
@@ -150,12 +150,12 @@ pub fn unwrap(data: RemoteData(a, error), or default: a) -> a {
150
150
/// Convert a RemoteData to an Option
151
151
/// ## Examples
152
152
/// ```gleam
153
- /// to_option(data: Success(42 ))
154
- /// // -> Some(42 )
153
+ /// to_option(Success(1 ))
154
+ /// // -> Some(1 )
155
155
/// ```
156
156
///
157
157
/// ```gleam
158
- /// to_option(data: Failure("error"))
158
+ /// to_option(Failure("error"))
159
159
/// // -> None
160
160
/// ```
161
161
pub fn to_option ( data : RemoteData ( a, error) ) -> Option ( a) {
@@ -168,8 +168,8 @@ pub fn to_option(data: RemoteData(a, error)) -> Option(a) {
168
168
/// Convert an Option to a RemoteData
169
169
/// ## Examples
170
170
/// ```gleam
171
- /// from_option(option: Some(42 ), or: "error")
172
- /// // -> Success(42 )
171
+ /// from_option(option: Some(1 ), or: "error")
172
+ /// // -> Success(1 )
173
173
/// ```
174
174
///
175
175
/// ```gleam
@@ -187,17 +187,17 @@ pub fn from_option(option: Option(a), or error: error) -> RemoteData(a, error) {
187
187
/// If the data is NotAsked or Loading, it will be converted to an Error with the provided error
188
188
/// ## Examples
189
189
/// ```gleam
190
- /// to_result(data: Success(42 ), or: "error")
191
- /// // -> Ok(42 )
190
+ /// to_result(Success(1 ), or: "error")
191
+ /// // -> Ok(1 )
192
192
/// ```
193
193
///
194
194
/// ```gleam
195
- /// to_result(data: Failure("error"), or: "another error")
195
+ /// to_result(Failure("error"), or: "another error")
196
196
/// // -> Error("error")
197
197
/// ```
198
198
///
199
199
/// ```gleam
200
- /// to_result(data: Loading, or: "another error")
200
+ /// to_result(Loading, or: "another error")
201
201
/// // -> Error("another error")
202
202
/// ```
203
203
pub fn to_result (
@@ -214,8 +214,8 @@ pub fn to_result(
214
214
/// Convert a Result to a RemoteData
215
215
/// ## Examples
216
216
/// ```gleam
217
- /// from_result(result: Ok(42 ))
218
- /// // -> Success(42 )
217
+ /// from_result(result: Ok(1 ))
218
+ /// // -> Success(1 )
219
219
/// ```
220
220
///
221
221
/// ```gleam
@@ -232,12 +232,12 @@ pub fn from_result(result: Result(a, error)) -> RemoteData(a, error) {
232
232
/// Convert a list of RemoteData to a RemoteData of a list
233
233
/// ## Examples
234
234
/// ```gleam
235
- /// from_list([Success(42 ), Success(43 )])
236
- /// // -> Success([42, 43 ])
235
+ /// from_list([Success(1 ), Success(2 )])
236
+ /// // -> Success([1, 2 ])
237
237
/// ```
238
238
///
239
239
/// ```gleam
240
- /// from_list([Success(42 ), Failure("error")])
240
+ /// from_list([Success(1 ), Failure("error")])
241
241
/// // -> Failure("error")
242
242
/// ```
243
243
pub fn from_list (
@@ -252,7 +252,7 @@ pub fn from_list(
252
252
/// Check if a RemoteData is a Success
253
253
/// ## Examples
254
254
/// ```gleam
255
- /// is_not_asked(Success(42 ))
255
+ /// is_not_asked(Success(1 ))
256
256
/// // -> False
257
257
/// ```
258
258
///
@@ -270,13 +270,13 @@ pub fn is_not_asked(data: RemoteData(_, _)) -> Bool {
270
270
/// Check if a RemoteData is a Success
271
271
/// ## Examples
272
272
/// ```gleam
273
- /// is_loading(Success(42 ))
274
- /// // -> True
273
+ /// is_loading(Success(1 ))
274
+ /// // -> False
275
275
/// ```
276
276
///
277
277
/// ```gleam
278
- /// is_loading(Failure("error") )
279
- /// // -> False
278
+ /// is_loading(Loading )
279
+ /// // -> True
280
280
/// ```
281
281
pub fn is_loading ( data : RemoteData ( _, _) ) -> Bool {
282
282
case data {
@@ -288,13 +288,13 @@ pub fn is_loading(data: RemoteData(_, _)) -> Bool {
288
288
/// Check if a RemoteData is a Success
289
289
/// ## Examples
290
290
/// ```gleam
291
- /// is_failure(Success(42 ))
292
- /// // -> True
291
+ /// is_failure(Success(1 ))
292
+ /// // -> False
293
293
/// ```
294
294
///
295
295
/// ```gleam
296
296
/// is_failure(Failure("error"))
297
- /// // -> False
297
+ /// // -> True
298
298
/// ```
299
299
pub fn is_failure ( data : RemoteData ( _, _) ) -> Bool {
300
300
case data {
@@ -306,7 +306,7 @@ pub fn is_failure(data: RemoteData(_, _)) -> Bool {
306
306
/// Check if a RemoteData is a Success
307
307
/// ## Examples
308
308
/// ```gleam
309
- /// is_success(Success(42 ))
309
+ /// is_success(Success(1 ))
310
310
/// // -> True
311
311
/// ```
312
312
///
0 commit comments