concepts 0.2.0

  • Installing
  • Versions
  • 7


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.


  1. Associativity: a.merge(b).merge(c) is equivalent to a.merge(b.merge(c))


A Monoid is a SemiGroup that also implements an identity value.


  1. Right identity: m.merge(m.empty()) is equivalent to m
  2. Left identity: m.empty().merge(m) is equivalent to m
  3. Must also implement the SemiGroup laws (associativity).


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 map.


  1. Identity: => a) is equivalent to u
  2. Composition: => 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.


  1. Identity: const A((a) => a).ap(v) is equivalent to v
  2. Homomorphism: const A(f).ap(const A(x)) is equivalent to const A(f(x))
  3. Interchange: u.ap(const A(y)) is equivalent to const A((f) => f(y)).ap(u)
  4. Must also implement the Functor laws.


A monad is an applicative functor that lets you transition a value to a new context within the same type hierarchy.


  1. Left identity: const M(a).expand(f) is equivalent to f(a)
  2. Right identity: m.expand((n) => const M(n)) is equivalent to m
  3. Must also implement the Applicative laws.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  concepts: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:concepts/concepts.dart';
Version Uploaded Documentation Archive
0.2.0 Aug 19, 2014 Go to the documentation of concepts 0.2.0 Download concepts 0.2.0 archive
0.1.0 Aug 19, 2014 Go to the documentation of concepts 0.1.0 Download concepts 0.1.0 archive
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]
Learn more about scoring.

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.

Health suggestions

Format lib/concepts.dart.

Run dartfmt to format lib/concepts.dart.

Format lib/src/applicative.dart.

Run dartfmt to format lib/src/applicative.dart.

Format lib/src/functor.dart.

Run dartfmt to format lib/src/functor.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/monad.dart (Run dartfmt to format lib/src/monad.dart.)
  • lib/src/monoid.dart (Run dartfmt to format lib/src/monoid.dart.)
  • lib/src/semigroup.dart (Run dartfmt to format lib/src/semigroup.dart.)

Maintenance issues and suggestions

Add SDK constraint in pubspec.yaml. (-50 points)

For information about setting SDK constraint, please see

Package is too old. (-100 points)

The package was released more than two years ago.

Maintain (-20 points)

Changelog entries help clients to follow the progress in your code.

Homepage does not exists. (-20 points)

We were unable to access at the time of the analysis.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use concepts.dart.