- Added extension methods to work with nullable types (
T?
)- From
T?
tofpdart
's typestoOption
toEither
toTaskOption
toIOEither
toTaskEither
toTaskEitherAsync
fromNullable
(Either
,IOEither
,TaskOption
TaskEither
)fromNullableAsync
(TaskEither
)
- From
fpdart
's types toT?
toNullable
(Either
)
- From
/// [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
toEither
- Removed parameter from
Either
fromNullable
[⚠️ BREAKING CHANGE]
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
chainEither
toTaskEither
- Added
safeCast
(Either
andOption
) - Added
safeCastStrict
(Either
andOption
)
int intValue = 10;
/// Unhandled exception: type 'int' is not a subtype of type 'List<int>' in type cast
final waitWhat = intValue as List<int>;
final first = waitWhat.first;
/// Safe 🎯
final wellYeah = Either<String, List<int>>.safeCast(
intValue,
(dynamic value) => 'Not a List!',
);
final firstEither = wellYeah.map((list) => list.first);
- Added Open API Meteo example (from imperative to functional programming)
- Added new articles
- Option type and Null Safety in dart
- Either - Error Handling in Functional Programming
- Future & Task: asynchronous Functional Programming
- Flutter Supabase Functional Programming with fpdart
- Open Meteo API - Functional programming with fpdart (Part 1)
- Open Meteo API - Functional programming with fpdart (Part 2)
- Inverted
onSome
andonNone
functions parameters inmatch
method ofOption
[⚠️ 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
andsequence
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 inTaskEither
(#58)
/// Chain [Either] to [TaskEither]
TaskEither<String, int> binding =
TaskEither<String, String>.of("String").bindEither(Either.of(20));
- Added
lefts
,rights
, andpartitionEithers
methods toEither
(#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 toEither
,IOEither
, andTuple2
(#57) - Added
mapLeft
method toIOEither
(#57) - Added
fold
method toOption
(same asmatch
) (#56) - Fixed
chainFirst
forEither
,TaskEither
, andIOEither
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"
-
Updated README and documentation
-
Testing improvements (internal)
- Added testing utils
- Added Property-based testing using
glados
- Fixed tests for
match()
method by addingfail
in unexpected matched branch
-
Contribution improvements
- Added testing workflow with Github actions (#54)
- Refactoring for mixin breaking change (#42) by TimWhiting 🎉
- Added
chainFirst
method for the following classes (#39)TaskEither
Either
IO
IOEither
State
StateAsync
Reader
- Added
idFuture
andidentityFuture
methods (#38) by f-person 🎉 - Added
mapBoth
method toTuple2
(#30) - Fixed linting warnings
- Fixed issue with
upsert
method forMap
(#37)⚠️ - Minimum environment dart sdk to
2.16.0
⚠️
environment:
sdk: ">=2.16.0 <3.0.0"
- Updated package linting to
lints
- New methods to
TaskEither
,TaskOption
,Either
, andOption
mapLeft
(TaskEither
)bimap
(TaskEither
)toTaskEither
(Either
)toTaskOption
(Option
)
- New Blog posts and tutorials section in
README
- New blog post How to map an Either to a Future in fpdart
- Completed
IORef
type implementation, documentation, and testing- Merged PR (#25) by purplenoodlesoop 🎉
- Fixed major issue in
State
andStateAsync
implementation [BREAKING CHANGE]- Methods
flatMap
,map
,map2
,map3
,ap
,andThen
,call
, andflatten
had an implementation issue that has been now fixed
- Methods
- Released introduction to Practical Functional Programming
- Completed
StateAsync
type implementation, documentation, and testing - Fixed problem with
Alt
typeclass (#21) - Added
call
method to more easily chain functions inMonad
andMonad2
- Released two new tutorials on the
Option
type: - Added
toJson
andfromJson
methods toOption
to usejson_serializable
to convertOption
type to and from Json (using@JsonSerializable
) - Added functional extension methods on
Map
- Added composable
Predicate
type (and&
, or|
, not~
, xor^
) (#18)
- Released Part 3 of Fpdart, Functional Programming in Dart and Flutter
- Added Pure Functional Flutter app example (
pokeapi_functional
) - Added
flatMapTask
andtoTask
methods toIO
to lift and chainIO
withTask
- Added
flatMapTask
andtoTask
methods toIOEither
to lift and chainIOEither
withTaskEither
- Added pattern matching extension methods to
bool
(boolean.dart
) - Added functions to get random
int
,double
, andbool
in a functional way (usingIO
) (random.dart
) - Added functions, extension methods,
Ord
, andEq
instances toDateTime
(date.dart
)
- Released Part 2 of Fpdart, Functional Programming in Dart and Flutter
- Added
Compose
andCompose2
, used to easily compose functions in a chain - Added
curry
anduncurry
extensions on functions up to 5 parameters - Completed
TaskOption
type implementation, documentation, and testing - Expanded documentation and examples
- Added
TaskEither.tryCatchK
andEither.tryCatchK
, by tim-smart (#10, #11) 🎉
- Released Part 1 of Fpdart, Functional Programming in Dart and Flutter
- Added functional extension methods on
Iterable
(List
) - Completed
IOEither
type implementation, documentation, and testing - Added
constF
function - Added
option
andoptionOf
(same as dartz) - Added
Either.right(r)
factory constructor toEither
class (same asEither.of(r)
) (#3) - Added example on reading local file using
TaskEither
(read_write_file) - Added more examples
- Added constant constructors to Eq and variants, by mateusfccp (#4) 🎉
- Completed
State
type implementation, documentation, and testing - Completed
Reader
type implementation, documentation, and testing - Completed
IO
type implementation, documentation, and testing - Merged PR (#2) by jacobaraujo7 🎉
- Added
right
andleft
functions to create instance ofEither
- Added
id
function (same asidentity
) - Added
fold
method toEither
(same asmatch
) - Added
bind
method toEither
(same asflatMap
) - Added
bindFuture
method toEither
, which returnsTaskEither
- Added
- Completed
Unit
type documentation - Completed
Task
type implementation, documentation, and testing - Completed
TaskEither
type implementation, documentation, and testing - Completed implementation, documentation, and testing of
Foldable
instance onOption
andEither
[BREAKING CHANGE] - Completed
Tuple2
type implementation, documentation, and testing [BREAKING CHANGE] - Renamed
fold
method ofFoldable
tofoldLeft
[BREAKING CHANGE] - Updated methods API (
foldRight
,foldLeft
, etc.) ofFoldable
instances (Option
,Either
,Tuple
) [BREAKING CHANGE] IList
not longer working correctly (waiting for a better solution for immutable collections) [BREAKING CHANGE]
- Changed name of type
Maybe
toOption
to be inline with fp-ts, cats, and dartz [BREAKING CHANGE]
First major release:
Either
IList
Maybe
Reader
State
Task
TaskEither
Tuple
Unit
Alt
Applicative
Band
BoundedSemilattice
CommutativeGroup
CommutativeMonoid
CommutativeSemigroup
Eq
Extend
Filterable
Foldable
Functor
Group
Hash
HKT
Monad
Monoid
Order
PartialOrder
Semigroup
Semilattice
Either
curry
Maybe
Reader
State
Eq
Hash
PartialOrder