@@ -53,7 +53,7 @@ Fpdart is inspired by [fp-ts](https://gcanti.github.io/fp-ts/), [cats](https://t
5353
5454Would you like to know more about functional programming, fpdart, and how to use the package?
5555
56- [ ** Collection of tutorials on fpdart** ] ( https://www.sandromaglione.com/course/fpdart-functional-programming-dart-and-flutter )
56+ 📚 [ ** Collection of tutorials on fpdart** ] ( https://www.sandromaglione.com/course/fpdart-functional-programming-dart-and-flutter )
5757
5858Check out also this series of articles about functional programming with ` fpdart ` :
5959
@@ -81,7 +81,10 @@ dependencies:
8181
8282## ✨ Examples
8383
84- ### [Option](https://github.com/SandroMaglione/fpdart/blob/540431746d616d30fadf36cc9d1a77c14baf35f4/lib/src/option.dart#L40)
84+ ### [Option](./lib/src/option.dart)
85+ Used when a return value can be missing.
86+ > For example, when parsing a ` String` to `int`, since not all `String`
87+ > can be converted to `int`
8588
8689` ` ` dart
8790/// Create an instance of [Some]
@@ -112,7 +115,10 @@ final flatMap = option.flatMap((a) => Option.of(a + 10));
112115final tryCatch = Option.tryCatch(() => int.parse('invalid'));
113116` ` `
114117
115- ### [ Either] ( https://github.com/SandroMaglione/fpdart/blob/9da7cae3b9f9dc690ff3255004393c4b979183e9/lib/src/either.dart#L16 )
118+ # ## [Either](./lib/src/either.dart)
119+ Used to handle errors (instead of `Exception`s).
120+ > `Either<L, R>`: `L` is the type of the error (for example a `String` explaining
121+ > the problem), `R` is the return type when the computation is successful
116122
117123` ` ` dart
118124/// Create an instance of [Right]
@@ -150,6 +156,27 @@ final match = right.match(
150156final option = right.toOption();
151157` ` `
152158
159+ # ## [Task](./lib/src/task.dart)
160+ Wrapper around an async function (`Future`). Allows to compose asynchronous functions **that never fail**.
161+
162+ ` ` ` dart
163+ /// Create instance of [Task] from a value
164+ final Task<int> task = Task.of(10);
165+
166+ /// Create instance of [Task] from an async function
167+ final taskRun1 = Task(() async => 10);
168+ final taskRun2 = Task(() => Future.value(10));
169+
170+ /// Map [int] to [String]
171+ final Task<String> map = task.map((a) => '$a');
172+
173+ /// Extract the value inside [Task] by running its async function
174+ final int value = await task.run();
175+
176+ /// Chain another [Task] based on the value of the current [Task]
177+ final flatMap = task.flatMap((a) => Task.of(a + 10));
178+ ` ` `
179+
153180# ## [Reader](https://github.com/SandroMaglione/fpdart/blob/9da7cae3b9f9dc690ff3255004393c4b979183e9/lib/src/reader.dart#L5)
154181
155182View the [example folder for an explained usecase example](https://github.com/SandroMaglione/fpdart/tree/main/example/src/reader).
0 commit comments