Skip to content

Instantly share code, notes, and snippets.

@ShalokShalom
Last active July 8, 2025 06:32
Show Gist options
  • Save ShalokShalom/5e7b0c65e1507b2b9654a6e75e03a8ad to your computer and use it in GitHub Desktop.
Save ShalokShalom/5e7b0c65e1507b2b9654a6e75e03a8ad to your computer and use it in GitHub Desktop.

Schrödingers error handling

The Problem: The "Manual Unwrapping" Ceremony

In popular error handling systems like Swift's options or Go's error tuples,
the types that are used to represent missing data or potential errors, are just passive containers.

The standard operators like + for addition, or > for comparison, don't know how to work with them. This forces the programmer into a constant, repetitive ceremony when error handling;

a) Probing the container: Check if it holds a real value or a blank state.

b) Unwrap the value: If a value exists, take it out of the container.

c) Operate: Use the unwrapped value in the calculation.

d) Re-wrap the result: Put the result back into a new container.

This "manual unwrapping" of error handling is the source of a lot of boilerplate code.
Examples are match statements and commoon if err != nil blocks.

The actual business logic gets buried under layers of this repetitive container-management code.

Our Solution: Intelligent Operators

Our system eliminates this boilerplate by fundamentally changing where the unwrapping logic lives.
Instead of forcing you to do it manually every time, we build that intelligence directly into the operators themselves.

The Logic is Defined Once:

The logic for how to handle an blank value (represented by ⍬) is defined one time;
inside the definition of the + operator, the > operator, and so on.

Operators Become "Aware":

The + operator itself now knows that if it sees 10 + ⍬, the result is 10.
The > operator knows that 10 > ⍬ is true.

The operators are no longer dumb; they are aware of the concept of uncertainty.

This is because ⍬ reflects any operation applied to it.
So n × ⍬ returns n, and ⍬ ^ ⁿ outputs n, and ⍬ + ⍬ gives out , as does ⍬ × ⍬ also give out .

The Ceremony Vanishes:

Because the operators are intelligent, you no longer need to perform the manual unwrapping ceremony.
You can apply them directly to your ⍬ variables.

The code you write reflects your actual intent, instead of tedious mechanics for manual container management.

In short, we don't remove the probing logic.

Instead, we move it from your application code into the language's core definition. Where it becomes a powerful, and reusable feature. :)

This makes the type an active participant in any calculation.
The blank value is a constant value for each scalar type, that can be associated with it.

For example, besides having the value of 1 and 0, a bi-state ⍬ predicate type is also able to express the value of ⍬. A tri-state would also be able to express the constant ⍬, besides the values of −1, 0, and 1.

This can be called Schrödingers error handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment