rec-def-0.2: Recursively defined values

Data.Recursive.Bool

Description

The type RBool is like Bool, but allows recursive definitions:

>>> :{
  let x = RB.true
y = x RB.&& z
z = y RB.|| RB.false
in RB.get x
:}
True


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

>>> :{
  let x = x RB.&& y
y = y RB.&& x
in (RB.get x, RB.get y)
:}
(False,False)


Use RDualBool from Data.Recursive.DualBool if you want the greatest solution.

Synopsis

# Documentation

data RBool Source #

Like Bool, but admits recursive definitions, preferring the least solution.

Extracts the value of a RBool

RB.get (RB.mk b) === b
RB.get RB.true == True
RB.get RB.false == False
RB.get (r1 RB.&& r2) === (RB.get r1 && RB.get r2)
RB.get (r1 RB.|| r2) === (RB.get r1 || RB.get r2)

and :: [RBool] -> RBool Source #

RB.get (RB.and rs) === and (map RB.get rs)

or :: [RBool] -> RBool Source #

RB.get (RB.or rs) === or (map RB.get rs)
RB.get (RB.not r1) === not (RDB.get r1)

The identity function. This is useful when tying the knot, to avoid a loop that bottoms out:

let x = x in RB.get x

will not work, but

>>> let x = RB.id x in RB.get x
False


does.

RB.get (RB.id r) === RB.get r