fpdart 0.4.1 
fpdart: ^0.4.1 copied to clipboard
Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.
0.4.1 25 February 2023 #
- New methods for 
Optiontype (thanks to tim-smart π)flatMapNullableflatMapThrowable
 
final option = Option.of(10);
option.flatMapNullable((a) => a + 1); /// π `Some(11)`
option.flatMapThrowable((a) => a + 1); /// π `Some(11)`
option.flatMapNullable<int>((a) => null); /// π `None()`
option.flatMapThrowable<int>((a) => throw "fail"); /// π `None()`
- Improved support 
fromJsonforOptiontype (thanks [again] to tim-smart π)- Allow for decoding of non-primitive types (with custom 
fromJsonconstructors) 
 - Allow for decoding of non-primitive types (with custom 
 
/// `fromJson` on `DateTime` with `Option` type
final now = DateTime.now();
Option<DateTime>.fromJson(now.toIso8601String(), (a) => DateTime.parse(a as String)); /// π `Some(now)`
Option<DateTime>.fromJson("fail", (a) => DateTime.parse(a as String)); /// π `None()`
- New extension methods for 
Map(thanks [once again] to tim-smart π)extractextractMap
 
final map = <String, dynamic>{'a': 1, 'b': 2, 'c': 3, 'd': 4};
map.extract<int>('b'); /// π `Some(2)`
map.extract<String>('b'); /// π `None()`, not of type `String` β οΈ
final map = <String, dynamic>{'a': 1};
map.extractMap('a'); /// π `None()`, not a `Map`
final map = <String, dynamic>{'a': {'b': 2} };
map.extractMap('a'); /// π `Some({'b': 2})`
Option.ofandOption.nonefactoriesconst(thanks to f-person π)
Note: People who have the prefer_const_constructors lint enabled will notice a warning to use
constπ€
- New 
managing_importsexample (thanks to RandalSchwartz π) - Updated README introduction
 
0.4.0 16 December 2022 #
- Added extension methods to work with nullable types (
T?)- From 
T?tofpdart's typestoOptiontoEithertoTaskOptiontoIOEithertoTaskEithertoTaskEitherAsyncfromNullable(Either,IOEither,TaskOptionTaskEither)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 
toIOEithertoEither - Removed parameter from 
EitherfromNullable[β οΈ 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 
chainEithertoTaskEither - Added 
safeCast(EitherandOption) - Added 
safeCastStrict(EitherandOption) 
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)
 
 
0.3.0 11 October 2022 #
- Inverted 
onSomeandonNonefunctions parameters inmatchmethod 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 
traverseandsequencemethods (#55)traverseListtraverseListWithIndexsequenceListtraverseListSeqtraverseListWithIndexSeqsequenceListSeq
 
/// "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 
bindEithermethod inTaskEither(#58) 
/// Chain [Either] to [TaskEither]
TaskEither<String, int> binding =
    TaskEither<String, String>.of("String").bindEither(Either.of(20));
- Added 
lefts,rights, andpartitionEithersmethods 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 
bimapmethod toEither,IOEither, andTuple2(#57) - Added 
mapLeftmethod toIOEither(#57) - Added 
foldmethod toOption(same asmatch) (#56) - Fixed 
chainFirstforEither,TaskEither, andIOEitherwhen chaining on a failure (Left) (#47) by DevNico π - Added 
constto 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 addingfailin unexpected matched branch 
 - 
Contribution improvements
- Added testing workflow with Github actions (#54)
 
 
0.2.0 16 July 2022 #
- Refactoring for mixin breaking change (#42) by TimWhiting π
 - Added 
chainFirstmethod for the following classes (#39)TaskEitherEitherIOIOEitherStateStateAsyncReader
 
0.1.0 17 June 2022 #
0.0.13 26 January 2022 #
- New methods to 
TaskEither,TaskOption,Either, andOptionmapLeft(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
 
 
0.0.12 24 October 2021 #
- Completed 
IOReftype implementation, documentation, and testing- Merged PR (#25) by purplenoodlesoop π
 
 
0.0.11 22 September 2021 #
- Fixed major issue in 
StateandStateAsyncimplementation [BREAKING CHANGE]- Methods 
flatMap,map,map2,map3,ap,andThen,call, andflattenhad an implementation issue that has been now fixed 
 - Methods 
 
0.0.10 13 August 2021 #
- Released introduction to Practical Functional Programming
 - Completed 
StateAsynctype implementation, documentation, and testing - Fixed problem with 
Alttypeclass (#21) - Added 
callmethod to more easily chain functions inMonadandMonad2 
0.0.9 3 August 2021 #
- Released two new tutorials on the 
Optiontype: - Added 
toJsonandfromJsonmethods toOptionto usejson_serializableto convertOptiontype to and from Json (using@JsonSerializable) - Added functional extension methods on 
Map - Added composable 
Predicatetype (and&, or|, not~, xor^) (#18) 
0.0.8 13 July 2021 #
- Released Part 3 of Fpdart, Functional Programming in Dart and Flutter
 - Added Pure Functional Flutter app example (
pokeapi_functional) - Added 
flatMapTaskandtoTaskmethods toIOto lift and chainIOwithTask - Added 
flatMapTaskandtoTaskmethods toIOEitherto lift and chainIOEitherwithTaskEither - Added pattern matching extension methods to 
bool(boolean.dart) - Added functions to get random 
int,double, andboolin a functional way (usingIO) (random.dart) - Added functions, extension methods, 
Ord, andEqinstances toDateTime(date.dart) 
0.0.7 6 July 2021 #
- Released Part 2 of Fpdart, Functional Programming in Dart and Flutter
 - Added 
ComposeandCompose2, used to easily compose functions in a chain - Added 
curryanduncurryextensions on functions up to 5 parameters - Completed 
TaskOptiontype implementation, documentation, and testing - Expanded documentation and examples
 - Added 
TaskEither.tryCatchKandEither.tryCatchK, by tim-smart (#10, #11) π 
0.0.6 29 June 2021 #
- Released Part 1 of Fpdart, Functional Programming in Dart and Flutter
 - Added functional extension methods on 
Iterable(List) - Completed 
IOEithertype implementation, documentation, and testing - Added 
constFfunction - Added 
optionandoptionOf(same as dartz) - Added 
Either.right(r)factory constructor toEitherclass (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) π
 
0.0.5 20 June 2021 #
- Completed 
Statetype implementation, documentation, and testing - Completed 
Readertype implementation, documentation, and testing - Completed 
IOtype implementation, documentation, and testing - Merged PR (#2) by jacobaraujo7 π
- Added 
rightandleftfunctions to create instance ofEither - Added 
idfunction (same asidentity) - Added 
foldmethod toEither(same asmatch) - Added 
bindmethod toEither(same asflatMap) - Added 
bindFuturemethod toEither, which returnsTaskEither 
 - Added 
 
0.0.4 15 June 2021 #
- Completed 
Unittype documentation - Completed 
Tasktype implementation, documentation, and testing - Completed 
TaskEithertype implementation, documentation, and testing - Completed implementation, documentation, and testing of 
Foldableinstance onOptionandEither[BREAKING CHANGE] - Completed 
Tuple2type implementation, documentation, and testing [BREAKING CHANGE] - Renamed 
foldmethod ofFoldabletofoldLeft[BREAKING CHANGE] - Updated methods API (
foldRight,foldLeft, etc.) ofFoldableinstances (Option,Either,Tuple) [BREAKING CHANGE] IListnot longer working correctly (waiting for a better solution for immutable collections) [BREAKING CHANGE]
0.0.3 13 June 2021 #
- Changed name of type 
MaybetoOptionto be inline with fp-ts, cats, and dartz [BREAKING CHANGE] 
0.0.2 13 June 2021 #
First major release:
Types #
EitherIListMaybeReaderStateTaskTaskEitherTupleUnit
Typeclasses #
AltApplicativeBandBoundedSemilatticeCommutativeGroupCommutativeMonoidCommutativeSemigroupEqExtendFilterableFoldableFunctorGroupHashHKTMonadMonoidOrderPartialOrderSemigroupSemilattice
Examples #
EithercurryMaybeReaderState
0.0.1 28 May 2021 #
EqHashPartialOrder



