invert

Automatically generate a function’s inverse

https://github.com/typeclasses/invert

Version on this page:1.0.0.2@rev:3
LTS Haskell 22.17:1.0.0.4
Stackage Nightly 2023-12-26:1.0.0.4
Latest on Hackage:1.0.0.4

See all snapshots invert appears in

Apache-2.0 licensed by Chris Martin
Maintained by Chris Martin, Julie Moronuki
This version can be pinned in stack with:invert-1.0.0.2@sha256:31df7f6b0e9038b221dcb20f32f73cab0553e4f3c3d874d00bb0c8019ac537cb,2463

Module documentation for 1.0.0.2

This library deals with computing a function’s inverse. This is, of course, not possible in general, so the applicability of this library comes with some caveats:

  • The function’s domain must be enumerable, and preferably rather small. We provide a few suggestions and utilities for how to enumerate the domain.

  • The function’s codomain must belong to the Eq class. An Ord or Hashable instance is also nice, to accommodate a data structure for efficient lookups.

  • The functions for inverting injections, surjections, and bijections require some care to use correctly, because the library does not verify these properties.

The main purpose of this library is to provide documentation and convenience. It does not contain a great quantity of code, so a user hesitant to incur a dependency on the package might well choose only to read and borrow its techniques.