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:70d1a0a46bfdb9a5e073bafe9157ec75877b0d7b2d7715d4162cdbfecaa714ae,4207
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.