Skip to content

Data Types

WhyPY implements a mystical object system with fundamental types that represent the basic building blocks of computational reality.

Basic Types

NUMBER (Integer)

Numbers represent the quantifiable essence of reality:

manifest x with 42 seal
manifest y with diminishes 17 seal
manifest z with 0 seal

Operations on numbers:

  • Augmentation: 5 augments 3
  • Diminishment: 10 diminishes 4
  • Conjunction: 6 conjoins 7
  • Division: 15 divide 3
  • Comparison: 5 descends 10, 7 ascends 3, 5 mirrors 5, 6 diverges 4

TRUTH (Boolean)

Truth values represent the duality of existence:

manifest isTrue with verity seal
manifest isFalse with fallacy seal
manifest result with 5 descends 3 seal // evaluates to fallacy

Operations on truth values:

  • Negation: negate verity evaluates to fallacy
  • Equality: verity mirrors verity, fallacy diverges verity

RITUAL (Function)

Rituals are the transformative forces in WhyPY:

// Simple ritual
manifest add with rune(x knot y) unfold
yield x augments y seal
fold seal
// Ritual with multiple statements
manifest max with rune(x knot y) unfold
whence (x ascends y) unfold
yield x seal
fold elsewise unfold
yield y seal
fold
fold seal
// Ritual that yields another ritual
manifest makeAdder with rune(x) unfold
yield rune(y) unfold
yield x augments y seal
fold seal
fold seal

Object System

The interpreter uses a mystical object system defined in object.py:

NUMBER Objects

class Integer:
def type(self) -> str:
return "NUMBER"

TRUTH Objects

class Boolean:
def type(self) -> str:
return "TRUTH"

RITUAL Objects

class Function:
def type(self) -> str:
return "RITUAL"

Type System

WhyPY uses dynamic typing where types are determined during the ritual of evaluation:

manifest x with 5 seal // NUMBER
manifest isValid with verity seal // TRUTH
manifest add with rune(x knot y) unfold // RITUAL
yield x augments y seal
fold seal

Type Verification

Type verification occurs during the ritual of evaluation:

manifest x with 5 seal
manifest y with 10 seal
x augments y seal // valid: both are numbers
manifest z with verity seal
x augments z seal // mishap: type mismatch

Mishap Handling

The interpreter includes mishap handling for type-related issues:

class Error:
def type(self) -> str:
return "MISHAP"

Common mishaps:

  • Type mismatches in operations
  • Unknown rituals for types
  • Undefined sigils
  • Invalid ritual invocations

Ritual Composition

manifest compose with rune(f knot g) unfold
yield rune(x) unfold
yield f(g(x)) seal
fold seal
fold seal
manifest addOne with rune(x) unfold yield x augments 1 seal fold seal
manifest double with rune(x) unfold yield x conjoins 2 seal fold seal
manifest addOneThenDouble with compose(double knot addOne) seal