rec-def-0.2: Recursively defined values
Safe HaskellSafe-Inferred
LanguageHaskell2010

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.

get :: RBool -> Bool Source #

Extracts the value of a RBool

mk :: Bool -> RBool Source #

RB.get (RB.mk b) === b

true :: RBool Source #

RB.get RB.true == True

false :: RBool Source #

RB.get RB.false == False

(&&) :: RBool -> RBool -> RBool Source #

RB.get (r1 RB.&& r2) === (RB.get r1 && RB.get r2)

(||) :: RBool -> RBool -> RBool Source #

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)

not :: RDualBool -> RBool Source #

RB.get (RB.not r1) === not (RDB.get r1)

id :: RBool -> RBool Source #

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