Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.

Overview

Fpdart

GitHub: SandroMaglione Twitter: SandroMaglione

Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.

Fpdart is fully documented. You do not need to have any previous experience with functional programming to start using fpdart. Give it a try!

Fpdart is inspired by fp-ts, cats, and dartz.

Note: The package is still in early development. The API may change frequently and there will be many breaking changes. The documentation and testing is currently under development, but it is coming soon and fast. Follow my Twitter for daily updates.

πŸ“– Learn functional programming and fpdart

Would you like to know more about functional programming, fpdart, and how to use the package? Check out this series of articles about functional programming with fpdart:

  1. Fpdart, Functional Programming in Dart and Flutter
  2. How to use fpdart Functional Programming in your Dart and Flutter app
  3. Pure Functional app in Flutter – Pokemon app using fpdart and Functional Programming

🎯 Types

  • Option
  • Either
  • Unit
  • Task
  • TaskEither
  • State
  • Reader
  • Tuple
  • IO
  • Iterable (List) extension
  • IOEither
  • TaskOption
  • ReaderEither
  • ReaderTask
  • ReaderTaskEither
  • StateReaderTaskEither
  • Lens
  • Writer

πŸ’» Installation

# pubspec.yaml
dependencies:
  fpdart: ^0.0.8 # Check out the latest version

✨ Examples

Option

/// Create an instance of [Some]
final option = Option.of(10);

/// Create an instance of [None]
final none = Option<int>.none();

/// Map [int] to [String]
final map = option.map((a) => '$a');

/// Extract the value from [Option]
final value = option.getOrElse(() => -1);

/// Pattern matching
final match = option.match(
  (a) => print('Some($a)'),
  () => print('None'),
);

/// Convert to [Either]
final either = option.toEither(() => 'missing');

/// Chain computations
final flatMap = option.flatMap((a) => Option.of(a + 10));

/// Return [None] if the function throws an error
final tryCatch = Option.tryCatch(() => int.parse('invalid'));

Either

/// Create an instance of [Right]
final right = Either<String, int>.of(10);

/// Create an instance of [Left]
final left = Either<String, int>.left('none');

/// Map the right value to a [String]
final mapRight = right.map((a) => '$a');

/// Map the left value to a [int]
final mapLeft = right.mapLeft((a) => a.length);

/// Return [Left] if the function throws an error.
/// Otherwise return [Right].
final tryCatch = Either.tryCatch(
  () => int.parse('invalid'),
  (e, s) => 'Error: $e',
);

/// Extract the value from [Either]
final value = right.getOrElse((l) => -1);

/// Chain computations
final flatMap = right.flatMap((a) => Either.of(a + 10));

/// Pattern matching
final match = right.match(
  (l) => print('Left($l)'),
  (r) => print('Right($r)'),
);

/// Convert to [Option]
final option = right.toOption();

Reader

View the example folder for an explained usecase example.

State

View the example folder for an explained usecase example.

More

Many more examples are coming soon. Check out my website and my Twitter for daily updates.


πŸ’‘ Motivation

Functional programming is becoming more and more popular, and for good reasons.

Many non-functional languages are slowly adopting patterns from functional languages, dart included. Dart already supports higher-order functions, generic types, type inference. Other functional programming features are coming to the language, like pattern matching, destructuring, multiple return values, higher-order types.

Many packages are bringing functional patterns to dart, like the amazing freezed for unions/pattern matching.

Fpdart aims to provide all the main types found in functional languages to dart. Types like Option (handle missing values without null), Either (handle errors and error messages), Task (composable async computations), and more.

Goal

Differently from many other functional programming packages, fpdart aims to introduce functional programming to every developer. For this reason, every type and method is commented and documented directly in the code.

You do not need to have any previous experience with functional programming to start using fpdart.

Fpdart also provides real-world examples of why a type is useful and how it can be used in your application. Check out my website for blog posts and articles.

Comparison with dartz

One of the major pain points of dartz has always been is lack of documentation. This is a huge issue for people new to functional programming to attempt using the package.

dartz was released in 2016, initially targeting Dart 1.

dartz is also missing some features and types (Reader, TaskEither, and others).

Fpdart is a rewrite based on fp-ts and cats. The main differences are:

  • Fpdart is fully documented.
  • Fpdart implements higher-kinded types using defunctionalization.
  • Fpdart is based on Dart 2.
  • Fpdart is completely null-safe from the beginning.
  • Fpdart has a richer API.
  • Fpdart implements some missing types in dartz.
  • Fpdart (currently) does not provide implementation for immutable collections (ISet, IMap, IHashMap, AVLTree).

πŸ€” Roadmap

Being documentation and stability important goals of the package, every type will go through an implementation-documentation-testing cycle before being considered as 'stable'.

The roadmap for types development is highlighted below (breaking changes to 'stable' types are to be expected in this early stages):

  1. Option
    • Implementation
    • Documentation
    • Testing
  2. Either
    • Implementation
    • Documentation
    • Testing
  3. Unit
    • Implementation
    • Documentation
    • Testing
  4. Task
    • Implementation
    • Documentation
    • Testing
  5. TaskEither
    • Implementation
    • Documentation
    • Testing
  6. Tuple
    • Implementation
    • Documentation
    • Testing
  7. State
    • Implementation
    • Documentation
    • Testing
  8. Reader
    • Implementation
    • Documentation
    • Testing
  9. IO
    • Implementation
    • Documentation
    • Testing
  10. IOEither
    • Implementation
    • Documentation
    • Testing
  11. TaskOption
    • Implementation
    • Documentation
    • Testing
  12. ReaderEither
    • Implementation
    • Documentation
    • Testing
  13. ReaderTask
    • Implementation
    • Documentation
    • Testing
  14. ReaderTaskEither
    • Implementation
    • Documentation
    • Testing
  15. StateReaderTaskEither
    • Implementation
    • Documentation
    • Testing
  16. Writer
    • Implementation
    • Documentation
    • Testing
  17. Lens
    • Implementation
    • Documentation
    • Testing

Note: Integrations for immutable collections (IList, ISet, IMap, etc.) are still being discussed with the community. fpdart does not want to be another immutable collection solution in the ecosystem. That is why we are working to integrate fpdart with other more mature packages that already implements immutable collections. Stay tuned!

The long-term goal is to provide all the main types and typeclasses available in other functional programming languages and packages. All the types should be completely documented and fully tested.

A well explained documentation is the key for the long-term success of the project. Any article, blog post, or contribution is welcome.

In general, any contribution or feedback is welcome (and encouraged!).

πŸ“ƒ Versioning

  • v0.0.8 - 13 July 2021
  • v0.0.7 - 6 July 2021
  • v0.0.6 - 29 June 2021
  • v0.0.5 - 20 June 2021
  • v0.0.4 - 15 June 2021
  • v0.0.3 - 13 June 2021
  • v0.0.2 - 13 June 2021
  • v0.0.1 - 28 May 2021

πŸ˜€ Support

Currently the best way to support me would be to follow me on my Twitter.

Another option (or Option) would be to buy me a coffee.

πŸ‘€ License

MIT License, see the LICENSE.md file for details.

Comments
  • Can I use `Option.map` for side effect?

    Can I use `Option.map` for side effect?

    Hello! First of all, Thank you for your amazing work! I'm using fpdart with flutter. I have a quick question. Can I use Option.map for side effect? I think It will be working. But I'm not sure that.

    final optionValue = Option.of(true);
    optionValue.map((value) {
      print(value);
    })
    

    As the examples for Option. It's better that use match for side effect. But I don't need a None case.

    final optionValue = Option.of(true);
    optionValue.match(
      () => null,
      (value) => print(value),
    );
    

    Which one is better?

    question how to do that 
    opened by todd-kim 6
  • Unwrap variants for Option and Either

    Unwrap variants for Option and Either

    Hello! It would be great if there was a way to extract/unwrap the value contained in the Option and Either types. The unwrap terminology is used in Rust, and given that Dart is not a pure functional language sometimes it's useful to extract the value once you've checked it with isSome or isRight to do early returns. For instance say you return Left and you want to launch an error dialog (Flutter). You would want to break the flow of the program to show this dialog, else continue with the regular flow unwrapping the value of Right.

    Here is the API in Rust for reference For Rust Option -> https://doc.rust-lang.org/std/option/#extracting-the-contained-value For Rust Result (equivalent to Either) -> https://doc.rust-lang.org/std/result/#extracting-contained-values

    question 
    opened by davidmartos96 6
  • Question about tryCatch

    Question about tryCatch

    Hi, I have a question, as I am quite new to Functional programming and even imperative programming too.

    Let's say I have something like this

    class FirstException implements Exception {}
    
    class SecondException implements Exception {}
    
    class Student {
      final String name;
      Student(this.name);
    }
    
    class StudentRepo {
      static Future<List<Student>> getAllStudents() async => [
            Student('Juan'),
            Student('Maria'),
          ];
    }
    

    The question is how to handle only particular exception with tryCatch. In this case, I want to throw exception other than FirstException and SecondException because I heard catching all exceptions and errors are not good practice. But I am not sure how to handle this with functional way.

    Imperative way:

    Future<Either<String, List<Student>>> imperative() async {
      try {
        final students = await StudentRepo.getAllStudents();
        return right(students);
      } on FirstException {
        return left('FirstException');
      } on SecondException {
        return left('SecondException');
      }
      // I want to throw exception other than FirstException and SecondException
      // I want to avoid catch all exceptions without on clause
      // catch (e) {
      //   print(e);
      // }
    }
    

    Functional way:

    TaskEither<String, List<Student>> getStudents = TaskEither.tryCatch(
      () => StudentRepo.getAllStudents(),
      (e, s) => // how to handle exception here?
    );
    

    Sorry, I may have misunderstood the concept of functional programming and this may be a dumb question. Anyway, thank you for creating this wonderful package and very detailed documentation.

    question how to do that 
    opened by ykaito21 4
  • Refactor for mixin breaking change

    Refactor for mixin breaking change

    Fixes #41 Mixins will no longer be able to extend other mixins (Rather the super mixin should be specified in an on clause). This breaking change is already on flutter's master channel, which is causing build errors when depending on this library. https://github.com/dart-lang/sdk/issues/48167

    This change makes the mixin clause longer for many of the classes, but at least the tests seem to still pass. Other than one test which I'm assuming is related to this issue, which is already resolved on dart's master channel. https://github.com/dart-lang/sdk/commit/abedfaf62a2a426d44142dc97aa342524feedf8f

    opened by TimWhiting 4
  • Tuple3,4,5,6

    Tuple3,4,5,6

    What about we have Tuple3-6 or 8 as in this package https://pub.dev/packages/tuple. I can still do something hacky like Tuple2<First, Tuple2<Second, Third>> but it will be not very friendly.

    wontfix 
    opened by erabti 4
  • Predicate [feature request]

    Predicate [feature request]

    Hi!

    Any plans to support Predicate and composing predicates?

    Predicate:

    typedef Predicate<E> = bool Function(E element);
    

    composition:

    var Predicate<File> isEmpty;
    var Predicate<File> modifiedToday;
    files.where(isEmpty && modifiedToday);
    
    enhancement 
    opened by pihentagy 4
  • Testing Either List

    Testing Either List

    I had the problems with darts already and thought you might have a solution for that. How do I test an Either List type? Let's say I have the following simple test:

    
    import 'package:flutter_test/flutter_test.dart';
    import 'package:fpdart/fpdart.dart';
    
    void main() {
      String expectedLeft = "lefti";
      List<int> expectedRight = [1, 2, 3, 4, 5];
    
      group("test either", () {
        test("test left", () {
          final res = getExpected(true);
          expect(res, Left(expectedLeft));
        });
    
        test("test right", () {
          final res = getExpected(false);
          expect(res, Either.right(expectedRight));
        });
      });
    }
    
    Either<String, List<int>> getExpected(bool isLeft) {
      if (isLeft) {
        return Left("lefti");
      } else {
        return Right([1, 2, 3, 4, 5]);
      }
    }
    
    
    

    The second test failed, because of the deep list inequality (or no deep list equality test).

    How do you test this scenario in a simple manner?

    extra 
    opened by Babwenbiber 4
  • Future<T?> to TaskOption<T>

    Future to TaskOption

    Hi, i'm stuck in one part of my code, the thing is, my database provider brings me a Future<Map<String, Object>?>, so, i was trying to transform to TaskOption<Map<String, Object>> with not sucess, the only thing i've come to, is Task<Option<Map...>> .

    The closest approach is this code but it's not the best for me.

    late Future<Map<String,Object>?> example;
    final taskOp = TaskOption.flatten((TaskOption.fromTask(Task(example).map((ex) => Option.fromNullable(ex).toTaskOption()))));
    

    Is there any other alternative to get a TaskOption<T> object easily from Future?

    Thanks a lot, your work in this library is excellent πŸ’― and sorry foy my bad english 😒

    how to do that 
    opened by victor7w7r 3
  • Implement Sequence method for Either type only

    Implement Sequence method for Either type only

    Context

    Coming from a fp-ts background, I'm accustomed to be able to perform operations like sequenceT:

    const prog = pipe(
      arrayOfItems.map((item) => {
        return TE.tryCatch(
          async () => {
            return await fetch(`/some/api?input=${item}`);
          },
          (e) => new Error('Error')
        );
      }),
      TE.sequenceT
    );
    

    In other words, maybe I need to hit an API multiple times with a bunch of inputs, so this is an array of TaskEithers, but at the end of the day, I just want to abstract that out, await this task once, and get back the array of responses.

    I looked through the library for quite a long time and couldn't find anything like that in there yet, so I presumed that it's either called something else, or can be constructed somehow using Dart type magic, or just hasn't been implemented yet.

    Approach

    I'm quite new to Dart and am not fully up to speed with the Type system yet.

    My understanding is that a better long-term solution is to implement some kind of abstract interface for sequence, then each type (like Either, TaskEither, Option etc) would provide some kind of method for how to implement a particular step in the sequence combinator.

    I don't know how to do this yet, and also for my project I just need to unwrap Lists of Eithers at the moment. So I will be using this function in my code until this has been resolved in this project.

    It's more of a suggestion at this stage, and I'm happy to take some feedback as to how to better integrate this feature into the package and work on a more comprehensive solution.

    opened by richardhp 3
  • [QUESTION] How to await a map function

    [QUESTION] How to await a map function

    Hello,

    I just started using fpdart so I have what I believe is a noob question.

    I have a funcion that returns Future and I am using async/await.

    Inside that function, I have an Either. In non FP y would bifurcate my paths based on the either with an if statement. To be more "FPish" I tried to use map on the Either, but what I do on both paths is async, and should be awaited before the function continues.

    I tried doing
    either.map((left) async => await foo(), (right) async => await bar())

    which compiled, but it didn't work, as I can't await on either.map

    What should be the suggested way to use option/either .map in conjunction with await?

    enhancement question 
    opened by mbabuglia 3
  • Added new functions and wrapper

    Added new functions and wrapper

    Added Functions:

    bind -> Bind other Either. asyncBind -> same as Bind, but return Future fold -> same as match (Help people who used dartz to migrate)

    Wrappers:

    id -> Function wrapper for return the parameter; right -> Return Right(r) left -> Return Left(l) (These wrappers also help people who used dartz to migrate).

    enhancement 
    opened by jacobaraujo7 3
  • Show example in docs of mixing functional packages and renaming classes

    Show example in docs of mixing functional packages and renaming classes

    I wrote this recently for a customer:

    /// This file is used to export all the functional programming libraries used in
    /// the project. It also exports the [FpState] type alias, which is used to
    /// avoid conflicts with the [State] class from the Flutter SDK.
    ///
    import 'package:fpdart/fpdart.dart' as fpdart show State;
    
    /// The `fpdart` library is used to create functional programming constructs.
    export 'package:fpdart/fpdart.dart' hide State;
    
    /// The `tuple` library is used to create tuples, which are immutable lists of
    /// fixed length.
    export 'package:tuple/tuple.dart' show Tuple3, Tuple4, Tuple5, Tuple6, Tuple7;
    
    /// A type alias for the [State] class from the `fpdart` library.
    typedef FpState<S, A> = fpdart.State<S, A>;
    

    which we then put in lib/core/functional.dart and include that instead of fpdart or tuple. It's a handy way to show how to rename the classes that conflict with other SDK or third-party packages. Maybe this could go somewhere in the docs, or in one of the examples? It'd also be a great place to add extensions to fpdart's types, so it'd need only one include for the project.

    documentation how to do that 
    opened by RandalSchwartz 2
  • catch only specified exceptions vs all

    catch only specified exceptions vs all

    I'd have to go check the semantics of the other libraries but it would be nice to have distinctions of: try-catch for all vs for specific types

    Cats has helpers for nonFatal but I'm not sure how it will work given dart lets you throw and catch everything under the sun.

    One option is to follow Dart's Future with an optional test function.

    // from async/future.dart
    Future<T> catchError(Function onError, {bool test(Object error)?});
    

    Another option is to specify it via type

    class Test {
      static void catchOnly<T>(void Function() fn, void Function(T) onError) {
        try {
          fn();
        } on T catch(e) {
          onError(e);
        }
      }
    }
    
    main() {
      fnHandlerInt(int e) => print('Handling int: $e');
      fnHandlerError(Error e) => print('Handling Error: $e');
    
      print("1");
      Test.catchOnly(() => throw 1, fnHandlerInt);
      print('2');
      Test.catchOnly(() => 1 ~/ 0, fnHandlerError);
      print('3');
      Test.catchOnly(() => throw 1, fnHandlerError); // Uncaught Error
      print('4'); // unreachable
      // Output:
      // 1
      // Handling int: 1
      // 2
      // Handling Error: Unsupported operation: Result of truncating division is Infinity: 1 ~/ 0
      // 3
      // Uncaught Error: 1
    }
    

    It rarely a good idea to catch everything but the dart language doesn't offer classifications from a overflow/OOM versus a parsing error. A possible workout is to explicitly enumerate all the fatal errors and re-throw them immediately. Thoughts?

    question how to do that 
    opened by jcdang 1
  • list extension mis-typed(?) return values

    list extension mis-typed(?) return values

    I was looking at the "List" extension, and I see this:

      /// Insert element `t` at the beginning of the [Iterable].
      Iterable<T> prepend(T t) => [t, ...this];
    

    The return value is not an Iterable. It's a List. You could turn this function into an iterable with something like

        Iterable<T> prepend(T t) sync * { yield t; yield this* };
    

    I just think it'd be more honest, and better for intellisense if things that are by necessity returning a List say so. After all, you can call sort() on this output, but not with an Iterable, only if it's tagged as a List.

    Put another way, if we could keep Iterable to mean "might be infinite", it'd be possible to construct some very cool function applications!

    Edit: Idea... you could have both an iterable extension and a list extension, properly typing the function inputs!

    Edit 2: On discord, we've just demonstrated that Dart picks the most restrictive type in the case of identical signatures:

    extension<T> on Iterable<T> {
      void hello() => print('Hello from Iterable extension');
    }
    
    extension<T> on List<T> {
      void hello() => print('Hello from List extension');
    }
    
    void main() {
      List<String> list = [];
      list.hello(); // Hello from List extension
    
      Iterable<String> iterable = list;
      iterable.hello(); // Hello from Iterable extension
    }
    
    enhancement good first issue refactoring 
    opened by RandalSchwartz 3
  • Streams in FPDart

    Streams in FPDart

    I'm just in the middle of a major refactor which involves moving a lot of my Dartz code into FPDart. While going through your articles I found how amazing the TaskEither.tryCatch() is at cleaning up my code (πŸ˜™πŸ‘Œ) .

    But now I've come to my Streams and i'm drawing a bit of a blank on how to tidy them up and wonder if this is something that FPDart has a solution for? I'm currently returning Stream<Either<AlertsFailure, List<Alert>>>> in something like this:

    Stream<Either<AlertsFailure, List<Alert>>> watchAlerts() async* {
        final userOption = await _auth.getSignedInUser();
        final user = userOption.getOrElse(() => throw NotAuthenticatedError());
    
        final alertsRef = _firestore.allUserAlerts(user.uid.getOrCrash());
        yield* alertsRef.snapshots().map((query) {
          if (query.docs.isEmpty) {
            return const Left<AlertsFailure, List<Alert>>(AlertsFailure.noAlerts());
          }
          return Right<AlertsFailure, List<Alert>>(query.docs
              .map(
                (alert) => AlertModel.fromFirestore(alert).toDomain(),
              )
              .toList()
            ..sort((a, b) => b.dateCreated.compareTo(a.dateCreated)));
        }).onErrorReturnWith((e, stack) {
          if (e is FirebaseException && e.code.contains('permission-denied')) {
            return const Left<AlertsFailure, List<Alert>>(
                AlertsFailure.insufficientPermission());
          } else {
            return const Left<AlertsFailure, List<Alert>>(
                AlertsFailure.serverError());
          }
        });
      }
    

    i'm trying to imagine something like TaskEither to wrap the snapshot() but don't know how to handle errors from the stream. The other idea was that there might be some kind of StreamEither but no searching has brought up any examples.

    This could be my FP noobish-ness or maybe this is actually a feature request... or maybe this isn't something FP even deals with and then my Stream is the right solution?

    enhancement 
    opened by lloydrichards 5
  • Do Notation

    Do Notation

    Hello!

    Thank you for your awesome package, really helped me implement most of the concepts I learned from fp-ts in Flutter.

    But I do think it's missing something, and that is the Do Notation. I currently have a use case where I need to preserve values across multiple TaskEithers, and I think the Do Notation approach can solve this.

    Is there going to be a Do Notation implementation soon in fpdart? Or do you have an alternative approach to my case?

    Thank you!

    enhancement 
    opened by prazedotid 7
Releases(v0.4.0)
  • v0.4.0(Dec 16, 2022)

    • 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)
    /// [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]
    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 to TaskEither
    • Added safeCast (Either and Option)
    • Added safeCastStrict (Either and Option)
    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);
    
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Oct 11, 2022)

    • 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"
    
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Jul 16, 2022)

  • v0.1.0(Jun 17, 2022)

    • Added idFuture and identityFuture methods (#38 by f-person πŸŽ‰)
    • Added mapBoth method to Tuple2 (#30)
    • Fixed linting warnings
    • Fixed issue with upsert method for Map (#37) ⚠️
    • Minimum environment dart sdk to 2.16.0 ⚠️
    environment:
      sdk: ">=2.16.0 <3.0.0"
    
    Source code(tar.gz)
    Source code(zip)
  • v0.0.14(Jan 31, 2022)

  • v0.0.13(Jan 26, 2022)

  • v0.0.12(Oct 24, 2021)

  • v0.0.11(Sep 22, 2021)

    • Fixed major issue in State and StateAsync implementation [BREAKING CHANGE]
      • Methods flatMap, map, map2, map3, ap, andThen, call, and flatten had an implementation issue that has been now fixed
    Source code(tar.gz)
    Source code(zip)
  • v0.0.10(Aug 13, 2021)

  • v0.0.9(Aug 3, 2021)

  • v0.0.8(Jul 13, 2021)

    • Released Part 3 of Fpdart, Functional Programming in Dart and Flutter
    • Added Pure Functional Flutter app example (pokeapi_functional)
    • Added flatMapTask and toTask methods to IO to lift and chain IO with Task
    • Added flatMapTask and toTask methods to IOEither to lift and chain IOEither with TaskEither
    • Added pattern matching extension methods to bool (boolean.dart)
    • Added functions to get random int, double, and bool in a functional way (using IO) (random.dart)
    • Added functions, extension methods, Ord, and Eq instances to DateTime (date.dart)
    Source code(tar.gz)
    Source code(zip)
  • v0.0.7(Jul 6, 2021)

  • v0.0.6(Jun 29, 2021)

    • 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 and optionOf (same as dartz)
    • Added Either.right(r) factory constructor to Either class (same as Either.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) πŸŽ‰
    Source code(tar.gz)
    Source code(zip)
  • v0.0.5(Jun 20, 2021)

    • 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 and left functions to create instance of Either
      • Added id function (same as identity)
      • Added fold method to Either (same as match)
      • Added bind method to Either (same as flatMap)
      • Added bindFuture method to Either, which returns TaskEither
    Source code(tar.gz)
    Source code(zip)
  • v0.0.4(Jun 15, 2021)

    • 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 on Option and Either [BREAKING CHANGE]
    • Completed Tuple2 type implementation, documentation, and testing [BREAKING CHANGE]
    • Renamed fold method of Foldable to foldLeft [BREAKING CHANGE]
    • Updated methods API (foldRight, foldLeft, etc.) of Foldable instances (Option, Either, Tuple) [BREAKING CHANGE]
    • IList not longer working correctly (waiting for a better solution for immutable collections) [BREAKING CHANGE]
    Source code(tar.gz)
    Source code(zip)
  • v0.0.3(Jun 13, 2021)

  • v0.0.2(Jun 13, 2021)

    Types

    • Either
    • IList
    • Maybe
    • Reader
    • State
    • Task
    • TaskEither
    • Tuple
    • Unit

    Typeclasses

    • Alt
    • Applicative
    • Band
    • BoundedSemilattice
    • CommutativeGroup
    • CommutativeMonoid
    • CommutativeSemigroup
    • Eq
    • Extend
    • Filterable
    • Foldable
    • Functor
    • Group
    • Hash
    • HKT
    • Monad
    • Monoid
    • Order
    • PartialOrder
    • Semigroup
    • Semilattice

    Examples

    • Either
    • curry
    • Maybe
    • Reader
    • State
    Source code(tar.gz)
    Source code(zip)
Owner
Sandro Maglione
Learning pretty much everything 🌌 Typescript, Flutter, React | WebDev, MobileDev, UI/UX Design πŸ’» I love to read, learn and travel πŸ“–
Sandro Maglione
Megaflixz is a movie app for the movie lover in you. Includes all new and upcoming movies and TV series. Also has an option to save movies to watch later list

MegaflixZ MegaflixZ is a movie app for the movie lover in you. It is an app that displays new and upcoming movies and tv series. Team members Deepak M

Deepak Mathews Koshy 11 Aug 23, 2021
MobX for the Dart language. Hassle-free, reactive state-management for your Dart and Flutter apps.

Language: English | PortuguΓͺs | Chinese mobx.dart MobX for the Dart language. Supercharge the state-management in your Dart apps with Transparent Func

MobX 2.2k Dec 27, 2022
A flutter boilerplate project with GetX state management.

flutter_getx_boilerplate Languages: English (this file), Chinese. Introduction During my study of Flutter, I have been using the flutter_bloc state ma

Kevin Zhang 234 Jan 5, 2023
Flutter MVU architecture/state management package

mvu_flutter No mutability. No builders. No connectors. No reducers. No StreamControllers and subscription management. A truly declarative state manage

Yakov Karpov 7 Jul 29, 2021
Simple global state management for Flutter

Slices Slices is a minimalist state manegement, focused specifically for applications that needs a global state where different "pieces" of the applic

Erick 5 Jun 15, 2021
The modular state management solution for flutter.

The modular state management solution for flutter. Easy debugging : each event is predictable and goes into a single pipeline Centralized state : soli

AloΓ―s Deniel 44 Jul 6, 2022
Flutter State Management with provider :rocket:

Flutter - Gerenciamento de Estados com Provider Objetivos ao completar os estudos Aprenda a gerenciar o estado da sua aplicação com Single Source of T

Tiago Barbosa 0 Dec 6, 2021
A simple way to access state while robust and testable.

A state-management library that: catches programming errors at compile time rather than at runtime removes nesting for listening/combining objects ens

Remi Rousselet 3.9k Jan 3, 2023
Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.

Languages: English (this file), Indonesian, Urdu, Chinese, Brazilian Portuguese, Spanish, Russian, Polish, Korean, French. About Get Installing Counte

Jonny Borges 8k Jan 8, 2023
App to Watch Animes And Read Manga.

App To Watch Anime And Read Manga NOTE: Manga Section Contains 18+ content. Sometimes App may take some time to load. Constants Folder is removed from

null 8 Sep 12, 2021
Flutter Navigation - all types of navigation in flutter run main.tabBar.dart to see tabBar, and run main.dart to see the otheres

pop_up_bar A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Michael Odumosu 0 Jan 1, 2022
Examples of all types of widgets used for animation in Flutter.

Anny Flutter application for learning animations concept. Checkout the live demo here. License Copyright 2020 Ashutosh Singh Licensed under the A

Ashutosh Singh 23 Nov 22, 2022
A full, sound, modern and documented JS interop for Dart.

This is (or should be) a full JavaScript interop package using package:js bindings. The bindings are generated by machine-reading WebIDL files for typ

Jonathan Rezende 36 Dec 15, 2022
Simple access log parsing for zabbix (tested with nginx)

zabbix-nginx-stats Simple script to import basic nginx statistics into zabbix. It parses the log file (currently only supports one basic format) and p

Herbert Poul 32 Mar 18, 2022
Reactive Programming - BLoC - Practical Use Cases and Patterns

Reactive Programming - BLoC - Practical Use Cases and Patterns Source code of the article available on didierboelens.com This article introduces some

Didier Boelens 211 Dec 29, 2022
Experimenting with 6 examples of different types of simple and complex JSON structures in Flutter

Parsing complex JSON in Flutter Gives a detailed explanation of working with simple and complex JSON structures using dart:convert library in Flutter

Pooja Bhaumik 488 Jan 6, 2023
John Pfister 2 Feb 25, 2022
Dart port of FormCoreJS: A minimal pure functional language based on self dependent types.

FormCore.js port to Dart. So far only the parser and typechecker have been ported i.e. the FormCore.js file in the original repo. (Original readme fro

Modestas Valauskas 2 Jan 28, 2022