rec-def-0.1: Recusively defined values

Data.Recursive.Bool

Description

The type R Bool is ike Bool, but allows recursive definitions:

>>> :{
  let x = rTrue
y = x &&& z
z = y ||| rFalse
in getR x
:}
True


This finds the least solution, i.e. prefers False over True:

>>> :{
  let x = x &&& y
y = y &&& x
in (getR x, getR y)
:}
(False,False)


Use R (Dual Bool) from Data.Recursive.DualBool if you want the greatest solution.

Synopsis

# Documentation

data R a Source #

A value of type R a is a a, but defined using only specific operations (which you will find in the corresponding module, e.g. Data.Recursive.Bool), which allow recursive definitions.

You can use getR to extract the value.

Do not use the extracted value in the definition of that value, this will loop just like a recursive definition with plain values would.

getR :: HasPropagator a => R a -> a Source #

Extract the value from a R a. This must not be used when _defining_ that value.

getR rTrue == True
getR rFalse == False
getR (r1 &&& r2) === (getR r1 && getR r2)
getR (r1 ||| r2) === (getR r1 || getR r2)

rand :: [R Bool] -> R Bool Source #

getR (rand rs) === and (map getR rs)

ror :: [R Bool] -> R Bool Source #

getR (ror rs) === or (map getR rs)

rnot :: R (Dual Bool) -> R Bool Source #

getR (rnot r1) === not (getRDual r1)