talira

Free monads, free applicatives and cofree comonads for Haskell

open sourceBSD-3-Clausefree

free is a Haskell package of common definitions for working with free monads, free applicatives and cofree comonads. The free monad on a functor is the type of trees whose nodes are labeled with that functor's constructors, useful for tree-like structures and domain-specific languages; cofree comonads, its dual, describe branching streams and rose trees and can annotate syntax trees.

Problems it solves

  • build an embedded DSL with an interpreter in Haskell
  • separate a program's description from how it runs in Haskell
  • use a free monad over my own functor in Haskell

Features

  • free monads over any Functor
  • free applicatives
  • cofree comonads for branching streams, rose trees and annotated syntax trees
  • building blocks for domain-specific languages

Alternatives

The same job

These do what free does.

  1. semigroupoids id-free versions of Haskell's Category, Applicative, Monad and related type classes
  2. transformers Concrete functor and monad transformers for Haskell
  3. adjunctions Adjunctions and representable functors for Haskell

Compare free with the top 3