functor-combinators: Tools for functor combinator-based program design

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Tools for working with functor combinators: types that take functors (or other indexed types) and returns a new functor that "enhances" or "mixes" them in some way. In the process, you can design featureful programs by composing smaller "primitives" using basic unversal combinators.

The main entry point is Data.Functor.Combinators, but more fine-grained functionality and extra combinators (some of them re-implementations for compatibility) are available in other modules as well.

This library does not define new functor combinators for the most part, but rather re-exports them from different parts of the Haskell ecosystem and provides a uniform interface.

See the README for a quick overview, and also https://blog.jle.im/entry/functor-combinatorpedia.html for an in-depth dive into the motivation behind functor combinator-driven development, examples of the functor combinators in this library, and details about how to use these abstractions!


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.1.0, 0.1.1.1, 0.2.0.0, 0.3.0.0, 0.3.1.0, 0.3.2.0, 0.3.3.0, 0.3.4.0, 0.3.4.1, 0.3.4.2, 0.3.5.0, 0.3.5.1, 0.3.6.0, 0.4.0.0, 0.4.1.0, 0.4.1.1, 0.4.1.2, 0.4.1.2, 0.4.1.3
Change log CHANGELOG.md
Dependencies assoc, base (>=4.12 && <5), bifunctors, comonad, constraints, containers, contravariant, deriving-compat, free, hashable, invariant, kan-extensions, mmorph, mtl, natural-transformation, nonempty-containers (>=0.3.4.4), pointed, profunctors, semigroupoids, sop-core, StateVar, tagged, these, transformers, trivial-constraint (>=0.5), unordered-containers, vinyl [details]
License BSD-3-Clause
Copyright (c) Justin Le 2019
Author Justin Le
Maintainer justin@jle.im
Category Data
Home page https://github.com/mstksg/functor-combinators#readme
Bug tracker https://github.com/mstksg/functor-combinators/issues
Source repo head: git clone https://github.com/mstksg/functor-combinators
Uploaded by jle at 2023-01-30T00:45:37Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for functor-combinators-0.4.1.2

[back to package description]

functor-combinators

Introductory Blog Post / Hackage

Tools for working with functor combinators: types that take functors (or other indexed types) and returns a new functor that "enhances" or "mixes" them in some way.

The main functionality is exported in Data.Functor.Combinators, but more fine-grained functionality and extra combinators (some of them re-implementations for compatibility) are available in other modules as well.

The goal is to represent schemas, DSL's, and computations (things like parsers, things to execute, things to consume or produce data) by assembling "self-evident" basic primitives and subjecting them to many different successive transformations and combiners. The process of doing so:

  1. Forces you to make explicit decisions about the structure of your computation type as an ADT.
  2. Allows you to retain isolation of fundamental parts of your domain as separate types
  3. Lets you manipulate the structure of your final computation type through normal Haskell techniques like pattern matching. The structure is available throughout the entire process, so you can replace individual components and values within your structure.
  4. Allows you to fully reflect the structure of your final computation through pattern matching and folds, so you can inspect the structure and produce useful summaries.

The main benefit of this library in specific is to allow you to be able to work with different functor combinators with a uniform and lawful interface, so the real functionality here is the wide variety of functor combinators from all around the Haskell ecosystem. This library does not provide the functor combinators, as much as it re-exports them with a unified interface. However, it does "fill in the matrix", in a sense, of functor combinators in specific roles that are missing from the haskell ecosystem.

To jump into using it, import Data.Functor.Combinator. For a full introduction, check out the Functor Combinatorpedia, which goes in-depth into the motivation behind functor combinator-driven development, examples of the functor combinators in this library, and details about how to use these abstractions!

Comparisons

On the surface, functor-combinators look like it fills a similar space to effects systems and libraries like mtl, polysemy, freer-simple, or fused-effects. However, the functor combinator design pattern actually exists on a different level.

Functor combinator design patterns can be used to help build the structure of the data types and schemas that define your program/DSL. Once you build these nice structures, you then interpret them into some target context. This "target context" is the realm that libraries like mtl and polysemy can fill; functor combinators serve to help you define a structure for your program before you interpret it into whatever Applicative or Monad or effects system you end up using.