Data.Bool

A Bool type can hold two primitive values: True and False. When starting designing Rawr, we decided to use True and False as constructors, in a Haskell-like way, but we would have great troubles with performance and capabilities, as much as simple logic-values would be an object, an instance of a class.

Operations

_and :: (Bool, Bool) -> Bool

Returns Bool (True) if both the value of the object and the value of the received expression are true. Otherwise, false.

<?php
  Bool (True) -> _and (Bool (False)); # => Bool (False)
  Bool (True) -> _and (Bool (True));  # => Bool (True)
_or :: (Bool, Bool) -> Bool

Returns Bool (True) if any of the values, of the object, or of the received expression, are true. Otherwise, false.

<?php
  Bool (False) -> _or (Bool (True));  # => Bool (True)
  Bool (False) -> _or (Bool (False)); # => Bool (False)
diff :: (Bool, Bool) -> Bool

Comparison of the difference of two objects or values of same type.

<?php
  Bool (True) -> diff (Bool (True));  # => Bool (False)
  Bool (True) -> diff (Bool (False)); # => Bool (True)
eq :: (Bool, Bool) -> Bool

Comparison of the equality of two objects or values of same type.

<?php
  Bool (True) -> diff (Bool (True));  # => Bool (True)
  Bool (True) -> diff (Bool (False)); # => Bool (False)
greaterOrEq :: (Bool, Bool) -> Bool

Returns if the value of this object is greater or equal to the received value.

<?php
  Bool (True) -> greaterOrEq (Bool (False)); # => Bool (True)
greaterThan :: (Bool, Bool) -> Bool

Returns if the value of this object is greater than the received value.

<?php
  Bool (False) -> greaterThan (Bool (True)); # => Bool (False)
ifTrue :: (Bool, Func) -> Bool

The closure passed as parameter is called if the value of this object is Bool (True). After, it returns the value by itself to allow method-chaining.

<?php
  Bool (True) -> ifTrue (Lambda (function () {
    Str ("Pass") -> putStrLn ();
  })); # => Bool (True)
ifFalse :: (Bool, Func) -> Bool

the closure passed as parameter is called if the value of this object is Bool (False). After, it returns the value by itself to allow method-chaining.

<?php
  Bool (False) -> ifFalse (Lambda (function () {
    Str ("None") -> putStrLn ();
  })); # => Bool (False)
lesserOrEq :: (Bool, Bool) -> Bool

Returns if the value of this object is lesser or equal to the received value.

<?php
  Bool (False) -> lesserOrEq (Bool (True)); # => Bool (True)
lesserThan :: (Bool, Bool) -> Bool

Returns if the value of this object is lesser than the received value.

<?php
  Bool (True) -> lesserThan (Bool (False)); # => Bool (False)
not :: Bool -> Bool

Reverses the value of a boolean object.

<?php
  Bool (True) -> not ();  # => Bool (False)
  Bool (False) -> not (); # => Bool (True)
otherwise :: Bool -> Bool

Alias for ifFalse.

<?php
  Bool (True)
  -> ifTrue (Lambda (function () {}))
  -> otherwise (Lambda (function () {})); # Bool (True)
thenElse :: (Bool, Func, Func) -> Bool

Equivalent to ifTrue and ifFalse.

<?php
  Bool (False)
  -> thenElse (
    Lambda (function (/* Then */) {
      Str ("...") -> putStrLn ();
    })
  , Lambda (function (/* Else */) {
      Str ("!!!") -> putStrLn ();
    })
  ); # Bool (True)