Ludwig.Equality

Module Members

structuralEquality

(Function)

Test for deep structural equality of two values.

Example:

x: structuralEquality(1, 1)                # => True
y: structuralEquality({foo: 1}, {foo: 1})  # => True
z: structuralEquality({foo: 1}, {foo: 2})  # => False

Comparing functions for equality will always result in False.

x: structuralEquality(fun x: x, fun x: x)  # => False

This implies that comparing data structures with embedded functions such as this one will also always result in false:

type Curve:
  name: String
  y:    fun(Int) -> Int

Another important thing to note is that comparing cyclical values for structural equality will not work, since that results in an infinite loop.

Type Signature

 fun (a, a) -> Bool
Argument: x

First value

Type: a

Argument: y

Second value

Type: a

Returns:

Whether or not the two values are structurally equal.

Type: Bool

structuralInequality

(Function)

Test if two values are not structurally equal. The opposite of structuralEquality.

Type Signature

 fun (a, a) -> Bool
Argument: x
Type: a
Argument: y
Type: a
Returns:
Type: Bool

logical NOT (!)=

(Operator)

operator != infixl 4:
  structuralInequality

Structural inequality test. See structuralInequality.


(Operator)

operator == infixl 4:
  structuralEquality

Structural equality test. See structuralEquality.