Traversable package:generic-data

Generic implementation of Foldable and Traversable. There is already a naive implementation using the generic Rep's own instances of Foldable and Traversable. However, deriving then generates a lot of code that may not be simplified away by GHC, that results in unnecessary run-time overhead. In contrast, this implementation guarantees that the generated code is identical to stock-derived instances of Foldable and Traversable, which have the following syntactic properties:
  • constructors with zero fields use pure once;
  • constructors with one field use fmap once;
  • constructors with n >= 2 fields use liftA2 once and (<*>) n-2 times.
The heavy lifting is actually done by the ap-normalize library.
Class of generic representations for which Traversable can be derived.
Internal definition of GTraversable.