Search packages, repositories and app categories

Package detailsv0.10.1

dartz

Functional Programming in Dart. Purify your Dart code using efficient immutable data structures, monads, lenses and other FP tools.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
583K
Likes
1.6K
Pub points
130

Install package

flutter pub add dartz

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Dartz is a Dart library that brings functional programming concepts to Dart, enabling developers to write cleaner, more predictable code. It provides immutable data structures, monads like Either and Option, and tools such as lenses for safe data manipulation. By promoting purity and avoiding side effects, Dartz helps manage errors and optional values in a type-safe way. Ideal for building robust, maintainable applications with clear error handling and state management.

Use cases

  • Error handling with Either
  • Managing optional values with Option
  • Building pure functions
  • Creating composable business logic
  • Implementing functional state management
  • Writing testable and maintainable code

Key features

  • Immutable data structures
  • Either monad for error handling
  • Option type for nullable values
  • Lenses for functional updates
  • Type-safe composition
  • Lightweight and performant

Suitable for

  • Developers seeking functional programming in Dart
  • Teams aiming for pure and testable code
  • Applications requiring robust error handling
  • Projects focused on clean architecture
  • Frontend and backend Dart applications

Considerations

  • Requires understanding of functional programming concepts
  • May increase learning curve for beginners
  • Not suitable for simple scripts or quick prototypes
  • Best used in larger, structured applications
  • Integration with non-functional code may require adaptation

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

dartz

License Pub.dev Github Stars

Functional programming in Dart

  • Type class hierarchy in the spirit of cats, scalaz and the standard Haskell libraries
  • Immutable, persistent collections, including IVector, IList, IMap, IHashMap, ISet and AVLTree
  • Option, Either, State, Tuple, Free, Lens and other tools for programming in a functional style
  • Evaluation, a Reader+Writer+State+Either+Future swiss army knife monad
  • Type class instances (Monoids, Traversable Functors, Monads and so on) for included types, as well as for several standard Dart types
  • Conveyor, an implementation of pure functional streaming
  • Examples, showcasing core concepts
New to functional programming?

A good place to start learning is the excellent Functional Programming in Scala by Paul Chiusano and Rúnar Bjarnason. I can not recommend this book highly enough.
You can also take a look at Category Theory for Programmers by Bartosz Milewski.

Status
  • Starting with version 0.10.0, Dart 2.12+ is required
  • 0.9.x supports Dart 1 and older Dart 2 versions
  • Basic type class structure and collection classes are relatively stable, but might see restructuring in future releases
  • Optimized for dart2js/node/v8, with performance on the dart vm being of distant secondary concern
  • Most things are stack safe and reasonably efficient, but there are a couple of exceptions and plenty of room for further optimizations
  • The streaming/conveyor stuff is highly experimental
  • The lens implementation is experimental and very bare bones
License/Disclaimer

See LICENSE

Categories

Source repository

Projects using this package