Skip to content

Implement algebraic type operations with Chinese character metaphors and set theory#10

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/resolve-canje-sum-types
Draft

Implement algebraic type operations with Chinese character metaphors and set theory#10
Copilot wants to merge 5 commits intomainfrom
copilot/resolve-canje-sum-types

Conversation

Copy link

Copilot AI commented Dec 27, 2025

Demonstrates the four fundamental algebraic type operations in TypeScript using mathematical and Chinese character analogies, with additional set-theoretic representation of numbers.

Implementation:

  • Sum types (Union): 一 | 二 = 三 — union types representing "A or B"
  • Product types (Intersection): 一 & 二 = 王 — intersection types combining properties
  • Quotient types: — type factoring and branded types for nominal typing
  • Subtraction types: 愛 - 心 = 爱 — type removal using Omit<T, K> and Exclude<T, U>
  • Set theory (Von Neumann ordinals): 3 = {∅, {∅}, {∅, {∅}}} — representing natural numbers as nested sets

Example:

// Sum: union of possibilities
type One = { value: 1; name: "一" };
type Two = { value: 2; name: "二" };
type Three = One | Two;  // 一 + 二 = 三

// Product: intersection of properties
type King = HorizontalStroke & VerticalElements;  // 一 × 二 = 王

// Subtraction: removal from types
type TraditionalLove = { heart: string; friend: string; grace: string; cover: string };
type SimplifiedLove = Omit<TraditionalLove, "heart">;  // 愛 - 心 = 爱

// Set theory: Von Neumann ordinals
type VonNeumannThree = {
    zero: VonNeumannZero;
    one: VonNeumannOne;
    two: VonNeumannTwo;
}; // 3 = {0, 1, 2} = {∅, {∅}, {∅, {∅}}}

Each operation includes practical examples demonstrating real-world usage patterns and connects type theory with set-theoretic foundations.

Original prompt

This section details on the original issue you should resolve

<issue_title>Canje</issue_title>
<issue_description>A sum type again.
1 + 2 = 3
一+二=三
A product type.
一+二=王
田 = a quotient type
A subtraction type
愛 - 心 = 爱(Simplified Chinese)</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@codesandbox
Copy link

codesandbox bot commented Dec 27, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copilot AI and others added 2 commits December 27, 2025 19:51
…raction types

Co-authored-by: ewdlop <25368970+ewdlop@users.noreply.github.com>
…ble values

Co-authored-by: ewdlop <25368970+ewdlop@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issues related to canje sum types and operations Implement algebraic type operations with Chinese character metaphors Dec 27, 2025
Copilot AI requested a review from ewdlop December 27, 2025 19:54
Copy link
Collaborator

@ewdlop ewdlop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 = {,{},{,{}}}
@copilot

@ewdlop ewdlop self-requested a review December 29, 2025 16:04
Copy link
Collaborator

@ewdlop ewdlop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3={,{},{,{}}

Copilot AI and others added 2 commits December 29, 2025 16:07
Co-authored-by: ewdlop <25368970+ewdlop@users.noreply.github.com>
…nment

Co-authored-by: ewdlop <25368970+ewdlop@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 29, 2025

3 = {,{},{,{}}}
@copilot

Added Von Neumann ordinals representation showing 3 = {∅, {∅}, {∅, {∅}}} in commit d7e32be. The implementation uses TypeScript types to model set containment with nested object structures.

Copilot AI changed the title Implement algebraic type operations with Chinese character metaphors Implement algebraic type operations with Chinese character metaphors and set theory Dec 29, 2025
Copilot AI requested a review from ewdlop December 29, 2025 16:09
Copy link
Collaborator

@ewdlop ewdlop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type Three = null | One | Two

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Canje

2 participants