Skip to content

Instantly share code, notes, and snippets.

@kiviuk
kiviuk / Sussman-object-oriented.md
Last active October 14, 2026 07:04
Sussman-object-oriented.md

Sussman Lecture 5B: Computational Objects

In Lecture 5B (from the 1986 MIT 6.001/SICP series), Sussman argues that assignment (state mutation) is not a necessary evil - it is the essential mechanism that allows programs to model the real world's fundamental notion of object identity and time.

Here are the core points he makes regarding Objects, Assignment, and the Real World:

1. The Real World Has "Objects" with Identity Independent of State

  • Functional/Substitution Model (Lecture 3A/4A): x = 3 then x = 4 is a contradiction. A name refers to a value. There is no time, only substitution.
  • Real World: You are the "same person" you were 10 years ago, even though almost every atom in your body has changed (state mutation). Your identity persists through state change.
  • Sussman's Point: To model this computationally, we need a mechanism where set! changes the contents of a structure without chang
@kiviuk
kiviuk / Pi_Agent_Patch
Created October 4, 2026 07:28
Pi_Agent_Patch
diff --git a/packages/tui/src/tui-alt-screen.ts b/packages/tui/src/tui-alt-screen.ts
index c0631f12f..c84f3b127 100644
--- a/packages/tui/src/tui-alt-screen.ts
+++ b/packages/tui/src/tui-alt-screen.ts
@@ -364,16 +364,27 @@ export class TuiAltScreen extends TuiBase implements ViewportTUI {
this.lastComponentClick = undefined;
this.resetRenderState();
const term = process.env.TERM?.toLowerCase() ?? "";
- // Multiplexers can lag when every pointer movement is forwarded. Button-motion
- // tracking preserves clicks, wheel events, selections, and scrollbar dragging.
@kiviuk
kiviuk / builder_pattern_scala.md
Last active September 20, 2026 16:15
builder_pattern_rocket
@kiviuk
kiviuk / builder_pattern_scala.md
Last active June 1, 2026 23:13
builder_pattern_scala

ToyOptionalRocket.scala

// Compile:  scalac ToyOptionalRocket.scala && scala ToyOptionalRocket

object ToyOptionalRocket:

    /* ----------------------- domain ----------------------------------- */
    case class Fuel(kind: String)
    case class Engine(thrust: Int)
@kiviuk
kiviuk / sql-fizz-buzz.sql
Last active May 31, 2026 21:41
sql-fizz-buzz.sql
CREATE TABLE `incr` (
`Id` int(11) NOT NULL auto_increment,
PRIMARY KEY (`Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DELIMITER ;;
CREATE PROCEDURE dowhile()
@kiviuk
kiviuk / Monad transformers down to earth by Gabriele Petronella.md
Last active April 6, 2026 21:17
Monad transformers down to earth by Gabriele Petronella

Significance of T in Monad Transformers

Observation

OptionT[Future, String] // wraps Future[Option[String]]

Reference

@kiviuk
kiviuk / natural-grouping-division.md
Last active June 1, 2026 20:07
natural-grouping-division.md

Core Concept

Modulo (%) inherently cycles through remainders (0, 1, 2, 0, 1, 2...). By mathematical design, it separates consecutive integers into different buckets: (x + 1) % n ≠ x % n (for n > 1)

To group consecutive values together, use integer division (/ or //). It truncates/floors the result, naturally clustering sequential indices into fixed-size chunks.

Formulas

| Goal | Formula | Notes |

@kiviuk
kiviuk / scala-type-class-vs-extension-methods.md
Last active June 1, 2026 21:39
scala-type-class-vs-extension-methods.md

Scala 3 Type Classes: The Type-Level Grid

When building software, we constantly face the same fundamental problem: How do we combine Data Types with Behaviors?

Imagine we have two dimensions:

  • The Data Axis: UserData, List, Tree
  • The Behavior Axis: Flyable, Processable, Serializable

How we combine these two dimensions defines the difference between Object-Oriented style and Functional style in Scala.

@kiviuk
kiviuk / hash-indexed-rules.md
Last active March 22, 2026 07:54
hash-indexed-rules.md

You have just unlocked one of the "Holy Grails" of enterprise software architecture.

Yes, applying the Unison philosophy (content-addressed, immutable, pure functions identified by hash) to regional business rules is not only possible, it solves the most agonizing problems in enterprise systems: Auditing, Versioning, and Time-Travel.

When building regional rules (e.g., EU VAT calculations, German labor compliance, US shipping tariffs), traditional codebases turn into a nightmare of nested if/else statements, feature flags, and date checks: if (country == "DE" && date > "2024-01-01" && date < "2025-01-01") { ... }