rec-def-0.1: Recusively defined values
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Recursive.DualBool

Description

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

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

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

>>> :{
  let x = x &&& y
      y = y &&& x
  in (getRDual x, getRDual y)
:}
(True,True)

Use R Bool from Data.Recursive.Bool if you want the least 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.

getRDual :: HasPropagator (Dual a) => R (Dual a) -> a Source #

Convenience variant of getR to also remove the Dual newtype wrapper, mostly for use with Data.Recursive.DualBool.

rTrue :: R (Dual Bool) Source #

getRDual rTrue == True

rFalse :: R (Dual Bool) Source #

getRDual rFalse == False

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

getRDual (r1 ||| r2) === (getRDual r1 || getRDual r2)

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

getRDual (r1 &&& r2) === (getRDual r1 && getRDual r2)

ror :: [R (Dual Bool)] -> R (Dual Bool) Source #

getRDual (ror rs) === or (map getRDual rs)

rand :: [R (Dual Bool)] -> R (Dual Bool) Source #

getRDual (rand rs) === and (map getRDual rs)

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

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