Concepts is a partial port of Haskell's type class hierarchy to Dart. This library contains interfaces only with no implementations. This allows us to leverage Dart's type checker in conjunction with Dart's package manager to create executable, versioned and linkable specifications which double as layers of interoperation via polymorphism.
Like the algebraic structures in the haskell type class hierarchy, each given implementation must satisfy the interface as well as satisfy the laws associated to that interface.
SemiGroup represents data structures which can be merged associatively. Some people get an intuition from this by saying that it's two structures which can be summed.
a.merge(b).merge(c)is equivalent to
A Monoid is a SemiGroup that also implements an identity value.
m.merge(m.empty())is equivalent to
m.empty().merge(m)is equivalent to
A functor is a structure which wraps a value and comes with a structure
preserving operations which allows you to transition the inner value to a new
state. This structure preserving operation is known as
u.map((a) => a)is equivalent to
u.map((x) => f(g(x)))is equivalent to
Applicative is a Functor lets you apply a function that is contained in a context itself to values that are also in the context.
const A((a) => a).ap(v)is equivalent to
const A(f).ap(const A(x))is equivalent to
u.ap(const A(y))is equivalent to
const A((f) => f(y)).ap(u)
A monad is an applicative functor that lets you transition a value to a new context within the same type hierarchy.
const M(a).expand(f)is equivalent to
m.expand((n) => const M(n))is equivalent to
Add this to your package's pubspec.yaml file:
dependencies: concepts: ^0.2.0
You can install packages from the command line:
$ pub get
Alternatively, your editor might support
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.2.0||Aug 19, 2014|
|0.1.0||Aug 19, 2014|
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.
Support Dart 2 in
The SDK constraint in
pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.
dartdoc successfully runs on your package's source files. (-10 points)
Dependencies were not resolved.