rec-def: Recusively defined values

[ bsd2, data, library ] [ Propose Tags ] [ Report a vulnerability ]

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

let s1 = rInsert 23 s2
    s2 = rInsert 42 s1
in getR s1

will not loop, but rather produces the set fromList [23,42]

See Data.Recursive.Examples for more examples, or just browse the modules

More APIs (e.g. for Natural) can be added over time, as need and good use-cases arise.

For the (unsafe) building blocks to build such APIs, see

The library is not (yet) focussed on performance, and uses a rather naive propagator implementation. Expect this to be slow if you have large graphs. This may be improved in the future (e.g. by propagating only deltas, and accumulating deltas before applying a function), but for now the focus is on foremost providing this capability in the first place and getting the user-facing API right.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.2, 0.2.1, 0.2.2
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), containers (>=0.5.11 && <0.7) [details]
Tested with ghc ==9.2.1, ghc ==9.0.2, ghc ==8.10.7, ghc ==8.8.4, ghc ==8.6.5, ghc ==8.4.4
License BSD-2-Clause
Copyright 2022 Joachim Breitner
Author Joachim Breitner
Maintainer mail@joachim-breitner.de
Revised Revision 1 made by JoachimBreitner at 2022-09-05T08:46:44Z
Category Data
Home page https://github.com/nomeata/haskell-rec-def
Bug tracker https://github.com/nomeata/haskell-rec-def/issues/new
Source repo head: git clone git://github.com/nomeata/haskell-rec-def
Uploaded by JoachimBreitner at 2022-09-03T12:31:43Z
Distributions LTSHaskell:0.2.2, NixOS:0.2.2, Stackage:0.2.2
Downloads 478 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-09-03 [all 1 reports]

Readme for rec-def-0.1

[back to package description]

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 = rInsert 23 s2
      s2 = rInsert 42 s1
  in getR s1
 :}
fromList [23,42]

See the examples.hs file for more examples.

It also provides (unsafe) building blocks to build such APIs, see Data.Recursive.R.Internal.

  • 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.