搜尋套件、儲存庫與 APP 分類

套件詳情v0.10.1

dartz

Dart 中的函數式程式設計。使用高效能的不可變資料結構、單子、透鏡及其他 FP 工具來淨化您的 Dart 程式碼。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
58.3萬
喜歡數
1560
Pub 分數
130

安裝套件

flutter pub add dartz

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Dartz 是一個 Dart 庫,將函數式程式設計概念帶入 Dart,讓開發者能夠撰寫更乾淨、更具預測性的程式碼。它提供不可變資料結構、Either 和 Option 等單子,以及用於安全資料操作的工具(例如透鏡)。透過提倡純粹性並避免副作用,Dartz 以類型安全的方式管理錯誤與選擇性值。非常適合建構具備明確錯誤處理與狀態管理的穩健、可維護應用程式。

適用情境

  • 錯誤處理與 Either
  • 使用 Option 管理可選值
  • 建構純函數
  • 建立可組合的業務邏輯
  • 實現功能狀態管理
  • 編寫可測試且可維護的程式碼

主要特色

  • 不可變資料結構
  • 用於錯誤處理的 Either monad
  • 可空值的選項類型
  • 用於函數式更新的鏡頭
  • 類型安全的組合
  • 輕量且高效

適合對象

  • 尋求在 Dart 中進行函數式程式設計的開發者
  • 致力於純粹且可測試程式碼的團隊
  • 需要強大錯誤處理的應用程式
  • 專注於清潔架構的項目
  • 前端和後端 Dart 應用程式

使用建議

  • 需要理解函數式程式設計概念
  • 可能增加初學者的學習曲線
  • 不適合簡單的腳本或快速原型
  • 最適合用於較大且結構化的應用程式
  • 與非功能程式碼的整合可能需要適應

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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

所屬分類

原始碼儲存庫

使用此套件的專案