Skip to content

Commit 5b4f0ac

Browse files
committed
Typo
1 parent 502d56a commit 5b4f0ac

20 files changed

Lines changed: 40 additions & 40 deletions

content/en/docs/e6.combinators.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,38 @@ slug: combinators
55

66
## What is a combinator?
77

8-
- One meaning of “combinator” is a more informal sense referring to the **combinator pattern**, a style of organizing libraries centered around the idea of combining things. Usually there is **some type T**, some **functions for constructing “primitive” values of type T**, and some “**combinators**” which can **combine values of type T** in various ways to **build up more complex values of type T**. The other definition is **"function with no free variables"**.
8+
- One meaning of “combinator” is a more informal sense referring to the combinator pattern, a style of organizing libraries centered around the idea of combining things. Usually there is some type T, some functions for constructing “primitive” values of type T, and some “combinators” which can combine values of type T in various ways to build up more complex values of type T. The other definition is "function with no free variables".
99
__ [wiki.haskell.org](https://wiki.haskell.org/Combinator)
1010

11-
- A combinator is **a function** which **builds program fragments from program fragments**; in a sense the programmer using combinators constructs much of the desired program automatically, rather that writing every detail by hand.
11+
- A combinator is a function which builds program fragments from program fragments; in a sense the programmer using combinators constructs much of the desired program automatically, rather that writing every detail by hand.
1212
__ John Hughes—[Generalizing Monads to Arrows](http://www.cse.chalmers.se/~rjmh/Papers/arrows.pdf) via [Functional Programming Concepts](https://github.com/caiorss/Functional-Programming/blob/master/haskell/Functional_Programming_Concepts.org)
1313

1414
The exact definition of "combinators" in Rust ecosystem is bit unclear. 
1515

1616
- `or()`, `and()`, `or_else()`, `and_then()`
17-
- **Combine two values of type T** and **return same type T**.
17+
- Combine two values of type T and return same type T.
1818

1919
- `xor()` for `Option` types
20-
- **Combine two values of type T** and **return same type T**, **only if exactly one value is T**
20+
- Combine two values of type T and return same type T, only if exactly one value is T
2121

2222
- `filter()` for `Option` types
23-
- **Filter type T** by using a closure as a conditional function
24-
- **Return same type T**
23+
- Filter type T by using a closure as a conditional function
24+
- Return same type T
2525

2626
- `map()`, `map_err()`
27-
- **Convert type T by applying a closure**.
28-
- The **data type of the value inside T can be changed**.
27+
- Convert type T by applying a closure.
28+
- The data type of the value inside T can be changed.
2929
ex. `Some<&str>` can be converted to `Some<usize>` or `Err<&str>` to `Err<isize>` and etc.
3030

3131
- `map_or()`, `map_or_else()`
32-
- **Transform type T by applying a closure** & **return the value inside type T**.
33-
- For **`None` and `Err`, a default value or another closure** is applied.
32+
- Transform type T by applying a closure & return the value inside type T.
33+
- For `None` and `Err`, a default value or another closure is applied.
3434

3535
- `ok_or()`, `ok_or_else()` for `Option` types
36-
- **Transform `Option` type into a `Result` type**.
36+
- Transform `Option` type into a `Result` type.
3737

3838
- `as_ref()`, `as_mut()`
39-
- **Transform type T into a reference or a mutable reference**.
39+
- Transform type T into a reference or a mutable reference.
4040

4141
## or() and and()
4242

@@ -101,7 +101,7 @@ assert_eq!(n.xor(n), n); // None1 xor None2 = None2
101101

102102
## or_else()
103103

104-
Similar to `or()`. The only difference is, the second expression should be a **[closure](/docs/functions/#closures)** which returns same type T.
104+
Similar to `or()`. The only difference is, the second expression should be a [closure](/docs/functions/#closures) which returns same type T.
105105

106106
### With Option
107107

@@ -138,7 +138,7 @@ assert_eq!(e1.or_else(fn_err), e2); // Err1 or_else Err2 = Err2
138138

139139
## and_then()
140140

141-
Similar to `and()`. The only difference is, the second expression should be a **[closure](/docs/functions/#closures)** which returns same type T.
141+
Similar to `and()`. The only difference is, the second expression should be a [closure](/docs/functions/#closures) which returns same type T.
142142

143143
### With Option
144144

@@ -176,7 +176,7 @@ assert_eq!(e1.and_then(fn_err), e1); // Err1 and_then Err2 = Err1
176176
## filter()
177177

178178
> [!tip]
179-
> Usually in programming languages `filter` functions are used with arrays or iterators to create a new array/ iterator by filtering own elements via a function/ closure. Rust also provides [`filter()` **as an iterator adaptor**](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter) to apply a closure on each element of an iterator to transform it into another iterator. However in here we are talking about the functionality of `filter()` with `Option` types.
179+
> Usually in programming languages `filter` functions are used with arrays or iterators to create a new array/ iterator by filtering own elements via a function/ closure. Rust also provides [`filter()` as an iterator adaptor](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter) to apply a closure on each element of an iterator to transform it into another iterator. However in here we are talking about the functionality of `filter()` with `Option` types.
180180
181181
The same `Some` type is returned, only if we pass a `Some` value and the given closure returned true for it. `None` is returned, if `None` type passed or the closure returned false. The closure uses the value inside `Some` as an argument. Still Rust support `filter()` only for `Option` types.
182182

@@ -195,9 +195,9 @@ assert_eq!(n.filter(fn_is_even), n); // None -> no value -> None
195195
## map() and map_err()
196196

197197
> [!tip]
198-
> Usually in programming languages `map()` functions are used with arrays or iterators, **to apply a closure on each element** of the array or iterator. Rust also provides [`map()` **as an iterator adaptor**](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.map) to apply a closure on each element of an iterator to transform it into another iterator. However in here we are talking about the functionality of `map()` with `Option` and `Result` types.
198+
> Usually in programming languages `map()` functions are used with arrays or iterators, to apply a closure on each element of the array or iterator. Rust also provides [`map()` as an iterator adaptor](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.map) to apply a closure on each element of an iterator to transform it into another iterator. However in here we are talking about the functionality of `map()` with `Option` and `Result` types.
199199
200-
- `map()` : Convert type T by applying a closure. **The data type of `Some` or `Ok` blocks can be changed** according to the return type of the closure. Convert `Option<T>` to `Option<U>`, `Result<T, E>` to `Result<U, E>`
200+
- `map()` : Convert type T by applying a closure. The data type of `Some` or `Ok` blocks can be changed according to the return type of the closure. Convert `Option<T>` to `Option<U>`, `Result<T, E>` to `Result<U, E>`
201201

202202
⭐ Via `map()`, only `Some` and `Ok` values are getting changed. No affect to the values inside `Err` (`None` doesn’t contain any value at all).
203203

@@ -231,7 +231,7 @@ assert_eq!(o1.map(fn_character_count), o2); // Ok1 map = Ok2
231231
assert_eq!(e1.map(fn_character_count), e2); // Err1 map = Err2
232232
```
233233

234-
- `map_err()` for `Result` types : **The data type of `Err` blocks can be changed** according to the return type of the closure. Convert `Result<T, E>` to `Result<T, F>`.
234+
- `map_err()` for `Result` types : The data type of `Err` blocks can be changed according to the return type of the closure. Convert `Result<T, E>` to `Result<T, F>`.
235235

236236
⭐ Via `map_err()`, only `Err` values are getting changed. No affect to the values inside `Ok`.
237237

@@ -250,7 +250,7 @@ assert_eq!(e1.map_err(fn_character_count), e2); // Err1 map = Err2
250250

251251
## map_or() and map_or_else()
252252

253-
Hope you remember the functionality of [`unwrap_or()` and `unwrap_or_else()`](/docs/unwrap-and-expect/#unwrap_or-unwrap_or_default-and-unwrap_or_else) functions. These functions also bit similar to them. But `map_or()` and `map_or_else()` apply a closure on `Some` and `Ok` values and **return the value inside type T**.
253+
Hope you remember the functionality of [`unwrap_or()` and `unwrap_or_else()`](/docs/unwrap-and-expect/#unwrap_or-unwrap_or_default-and-unwrap_or_else) functions. These functions also bit similar to them. But `map_or()` and `map_or_else()` apply a closure on `Some` and `Ok` values and return the value inside type T.
254254

255255
- `map_or()` : Support only for `Option` types (not supporting `Result`). Apply the closure to the value inside `Some` and return the output according to the closure. The given default value is returned for `None` types.
256256

@@ -293,7 +293,7 @@ assert_eq!(e.map_or_else(fn_default_for_result, fn_closure), 6);
293293

294294
## ok_or() and ok_or_else()
295295

296-
As mentioned earlier, `ok_or()`, `ok_or_else()` transform `Option` type into `Result` type. **`Some` to `Ok` and `None` to `Err`**.
296+
As mentioned earlier, `ok_or()`, `ok_or_else()` transform `Option` type into `Result` type. `Some` to `Ok` and `None` to `Err`.
297297

298298
- `ok_or()` : A default `Err` message should pass as argument.
299299

@@ -326,7 +326,7 @@ assert_eq!(n.ok_or_else(fn_err_message), e); // None -> Err(default)
326326

327327
## as_ref() and as_mut()
328328

329-
🔎 As mentioned earlier, these functions are used to **borrow type T as a reference or as a mutable reference**.
329+
🔎 As mentioned earlier, these functions are used to borrow type T as a reference or as a mutable reference.
330330

331331
- `as_ref()` : Convert `Option<T>` to `Option<&T>` and `Result<T, E>` to `Result<&T, &E>`
332332
- `as_mut()` : Converts `Option<T>` to `Option<&mut T>` and `Result<T, E>` to `Result<&mut T, &mut E>`

0 commit comments

Comments
 (0)