BSD-2-Clause licensed by Joachim Breitner
Maintained by [email protected]
This version can be pinned in stack with:rec-def-0.2@sha256:df1582859055ac14b9fa1e36e190713bc01be3ae135bed33aae360b202aae24d,4228
Depends on 2 packages(full list with versions):

rec-def - Pure recursive definition

This library provides safe APIs that allow you to define and calculate values recursively, and still get a result out:

>>> :{
  let s1 = RS.insert 23 s2
      s2 = RS.insert 42 s1
  in RS.get s1
 :}
fromList [23,42]

See the examples.hs file for more examples.

It also provides (unsafe) building blocks to build such APIs, see Data.Propagator.Purify.

Related work

  • Edward Kmett’s Data.Propagator.Prop module achieves something similar, and allows to construct more the graphs more flexibly, but requires a stricter phase control akin to runST.

  • Jeannin, Kozen and Silva’s work on “CoCaml: Functional Programming with Regular Coinductive Types” in Ocaml even goes a step further and not only allow the recursive definitions to be written down as here, but even allows functions consume regular recursive values, and still produces something that can be solved.

Changes

Revision history for rec-def

0.2 – 2022-09-22

  • The naive propagator does not use (==) to detect changes, but a custom operator, to allow faster and less restricted operators.
  • Module structure refactoring
  • No more R type constructor, instead individual RBool etc. types
  • Addition of Data.Recursive.Map
  • A space leak is fixed

0.1 – 2022-09-03

  • First version. Released on an unsuspecting world.