I watched Kmett’s talk on propagators, and maybe that gives me a bit more terminology to describe what I think I’m doing here, as there are two parts:
-
LBool
provides a monadic API to set up a propagator network, albeit a very simple one: All lattices involved are the two-point lattice consisting of “could beTrue
” < “definitelyFalse
”, and the only propagators isimplies
. It has a decent implementation to solve the propagation (I think it may even be optimal in some sense, but that’s easy with a two-point lattice). It requires the programmer to pay attention to register all relevant edges in the graph usingimplies
before reading off values usingcanBeTrue
.I think this can be built on top of Kmett’s
Cell
, with a newtype aroundBool
to have a specialPropagated
instance withmerge False _ = Change False False
. -
PBool
builds on top of that, but wraps it in a pure and safe API (consisting ofpFalse
,all
andunPBool
). This way, the programmer can define the propagator network using simple functional programming, without dealing with monads.
I am more excited about the latter, and I wonder how it compares to other approaches. For example, the propagators
library in Prop.hs
seems to achieve something similar, using reifyGraph
so that one can also use pure programs to define the program, but it seems it all has to happen within forward
and backwards
, so you can’t easily read off the cells as you go. So I hope I have hit a separate point in the design space… But I need to carve it out more precisely.
I should try to apply my construction to Kmett’s Cell
data structure from the propagator, as an alternative to his Prop.hs
, for a better comparison.