Skip to content

Commit

Permalink
updated CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMaglione committed Oct 24, 2022
1 parent 9207a3b commit 758976e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
# v0.4.0 - Soon
- Added extension methods to work with nullable types (`T?`)
- From `T?` to `fpdart`'s types
- `toOption`
- `toEither`
- `toTaskOption`
- `toIOEither`
- `toTaskEither`
- `toTaskEitherAsync`
- `fromNullable` (`Either`, `IOEither`, `TaskOption` `TaskEither`)
- `fromNullableAsync` (`TaskEither`)
- From `fpdart`'s types to `T?`
- `toNullable` (`Either`)
```dart
/// [Option] <-> `int?`
int? value1 = 10.toOption().map((t) => t + 10).toNullable();
bool? value2 = value1?.isEven;
/// `bool?` -> [Either] -> `int?`
int? value3 = value2
.toEither(() => "Error")
.flatMap((a) => a ? right<String, int>(10) : left<String, int>("None"))
.toNullable();
/// `int?` -> [Option]
Option<int> value4 = (value3?.abs().round()).toOption().flatMap(Option.of);
```
- Added `toIOEither` to `Either`
- Removed parameter from `Either` `fromNullable` [⚠️ **BREAKING CHANGE**]
```dart
final either = Either<String, int>.fromNullable(value, (r) => 'none');
/// 👆 Removed the value `(r)` (it was always null anyway 💁🏼‍♂️) 👇
final either = Either<String, int>.fromNullable(value, () => 'none');
```
- Added article about [Option type and Null Safety in dart](https://www.sandromaglione.com/techblog/option_type_and_null_safety_dart)

# v0.3.0 - 11 October 2022
- Inverted `onSome` and `onNone` functions parameters in `match` method of `Option` [⚠️ **BREAKING CHANGE**] (*Read more on why* 👉 [#56](https://github.com/SandroMaglione/fpdart/pull/56))
```dart
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Check out also this series of articles about functional programming with `fpdart
- [How to make API requests with validation in fpdart](https://www.sandromaglione.com/techblog/fpdart-api-request-with-validation-functional-programming)
- [How to use TaskEither in fpdart](https://www.sandromaglione.com/techblog/how-to-use-task-either-fpdart-functional-programming)
- [How to map an Either to a Future in fpdart](https://blog.sandromaglione.com/techblog/from-sync-to-async-functional-programming)
- [Option type and Null Safety in dart](https://www.sandromaglione.com/techblog/option_type_and_null_safety_dart)

## 💻 Installation

Expand Down
6 changes: 6 additions & 0 deletions example/src/option/nullable/chain_nullable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import 'package:fpdart/fpdart.dart';
int? nullable() => Random().nextBool() ? 10 : null;

void main(List<String> args) {
/// [Option] <-> `int?`
int? value1 = 10.toOption().map((t) => t + 10).toNullable();

bool? value2 = value1?.isEven;

/// `bool?` -> [Either] -> `int?`
int? value3 = value2
.toEither(() => "Error")
.flatMap((a) => a ? right<String, int>(10) : left<String, int>("None"))
.toNullable();

/// `int?` -> [Option]
Option<int> value4 = (value3?.abs().round()).toOption().flatMap(Option.of);

Option<int> value = (10
Expand Down

0 comments on commit 758976e

Please sign in to comment.