BSD-2-Clause licensed by Joachim Breitner
Maintained by [email protected]
This version can be pinned in stack with:rec-def-0.2.2@sha256:2e68a169994a4c331698949ac92f60c5960608dd4d0ceb7529bf6a4b7d5eb104,4348
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.2 – 2023-08-19

  • Add RMap.map and RMap.mapWithKey

0.2.1 – 2023-02-18

  • Add Data.Recursive.Set.when

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.