Skip to content

v0.3.0

Compare
Choose a tag to compare
@SandroMaglione SandroMaglione released this 11 Oct 13:07
· 232 commits to main since this release
e844fd9
  • Inverted onSome and onNone functions parameters in match method of Option [⚠️ BREAKING CHANGE] (Read more on why 👉 #56)
/// Everywhere you are using `Option.match` you must change this:
final match = option.match(
  (a) => print('Some($a)'),
  () => print('None'), // <- `None` second 👎 
);

/// to this (invert parameters order):
final match = option.match(
  () => print('None'), // <- `None` first 👍
  (a) => print('Some($a)'),
);
  • Added traverse and sequence methods (#55)
    • traverseList
    • traverseListWithIndex
    • sequenceList
    • traverseListSeq
    • traverseListWithIndexSeq
    • sequenceListSeq
/// "a40" is invalid 💥
final inputValues = ["10", "20", "30", "a40"];

/// Verify that all the values can be converted to [int] 🔐
///
/// If **any** of them is invalid, then the result is [None] 🙅‍♂️
final traverseOption = inputValues.traverseOption(
  (a) => Option.tryCatch(
    /// If `a` does not contain a valid integer literal a [FormatException] is thrown
    () => int.parse(a),
  ),
);
  • Added bindEither method in TaskEither (#58)
/// Chain [Either] to [TaskEither]
TaskEither<String, int> binding =
    TaskEither<String, String>.of("String").bindEither(Either.of(20));
  • Added lefts, rights, and partitionEithers methods to Either (#57)
final list = [
  right<String, int>(1),
  right<String, int>(2),
  left<String, int>('a'),
  left<String, int>('b'),
  right<String, int>(3),
];
final result = Either.partitionEithers(list);
expect(result.first, ['a', 'b']);
expect(result.second, [1, 2, 3]);
  • Added bimap method to Either, IOEither, and Tuple2 (#57)
  • Added mapLeft method to IOEither (#57)
  • Added fold method to Option (same as match) (#56)
  • Fixed chainFirst for Either, TaskEither, and IOEither when chaining on a failure (Left) (#47) by DevNico 🎉
  • Added const to all constructors in which it was missing (#59)
  • Minimum environment dart sdk to 2.17.0 ⚠️
environment:
  sdk: ">=2.17.0 <3.0.0"