package traverse

  1. Overview
  2. Docs
Traversable data structures with applicative functors

Install

Dune Dependency

Authors

Maintainers

Sources

v0.1.0.tar.gz
sha512=d9263ae793013ba0fd653831922c03388659123be0d122cce43e1912ef8388487e5ef693013d5549006063cc76ab6af2c372a6240283e24bac5a67cab95c7428

README.md.html

traverse: Traversable data structures with applicative functors

This library provides:

  • a module signature Traverse.Applicative.S for applicative functors [McBride and Patterson, 2008],

  • two functions Traverse.list and Traverse.seq to traverse lists and sequences by a given applicative functor and with a given arity,

  • many instances of applicative functors: Traverse.Applicative.{iter, map, reduce, env, fold, pair, forall, exists, option, result, list}.

The purpose of this library is to provide a common dictionary of "visitors", which is orthogonal to the visited data structure. For instance, Traverse.list Traverse.Applicative.iter (S O) is equivalent to List.iter, Traverse.list Traverse.Applicative.map (S (S O)) is equivalent to List.map2, etc. Moreover, one can get a visitor which combine, for instance, both List.map and List.fold_left by invoking Traverse.list Traverse.Applicative.(pair map fold). To get the same visitors for a sequence ('a Seq.t), one just have to replace Traverse.list by Traverse.seq, and it is easy to define a traversal for any algebraic data structures.

OCaml

Innovation. Community. Security.