Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
🀄️ on swiftc
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
giginet
PRO
April 14, 2026
Technology
70
0
Share
🀄️ on swiftc
https://tryswift.jp/
giginet
PRO
April 14, 2026
More Decks by giginet
See All by giginet
15年メンテしてきたdotfilesから開発トレンドを振り返る 2011 - 2026
giginet
PRO
2
290
Claude Codeログ基盤の構築
giginet
PRO
7
3.9k
Inside of Swift Export
giginet
PRO
1
2.2k
Swiftビルド弾丸ツアー - Swift Buildが作る新しいエコシステム
giginet
PRO
0
2.6k
SwiftでMCPサーバーを作ろう!
giginet
PRO
3
410
Creating Intuitive Developer Tool in Swift
giginet
PRO
0
1.5k
Mergeable Libraryで 高速なアプリ起動を実現しよう!
giginet
PRO
2
7k
5分でわかるExplicitly Built Modules
giginet
PRO
2
1.8k
Introduction for Open Source Swift Workshop
giginet
PRO
0
1.9k
Other Decks in Technology
See All in Technology
暗黙知について一歩踏み込んで考える - 暗黙知の4タイプと暗黙考・暗黙動へ
masayamoriofficial
0
110
シン・リスコフの置換原則 〜現代風に考えるSOLIDの原則〜
jinwatanabe
0
130
AI前提とはどういうことか
daisuketakeda
0
140
「できない」のアウトプット 同人誌『精神を壊してからの』シリーズ出版を 通して得られたこと
comi190327
3
600
Hooks, Filters & Now Context: Why MCPs Are the “Hooks” of the AI Era
miriamschwab
0
110
20260326_AIDD事例紹介_ULSC.pdf
findy_eventslides
0
590
サイバーフィジカル社会とは何か / What Is a Cyber-Physical Society?
ks91
PRO
0
150
ログ基盤・プラグイン・ダッシュボード、全部整えた。でも最後は人だった。
makikub
5
1.1k
バックオフィスPJのPjMをコーポレートITが担うとうまくいく3つの理由
yueda256
1
290
OCI技術資料 : ロード・バランサ 概要 - FLB・NLB共通
ocise
4
28k
ふりかえりを 「あそび」にしたら、 学習が勝手に進んだ / Playful Retros Drive Learning
katoaz
0
380
Babylon.js を使って試した色々な内容 / Various things I tried using Babylon.js / Babylon.js 勉強会 vol.5
you
PRO
0
250
Featured
See All Featured
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
95
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
880
Everyday Curiosity
cassininazir
0
190
Designing for Performance
lara
611
70k
The Cult of Friendly URLs
andyhume
79
6.8k
How to build a perfect <img>
jonoalderson
1
5.3k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
For a Future-Friendly Web
brad_frost
183
10k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
170
Faster Mobile Websites
deanohume
310
31k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.7k
Transcript
@giginet
🀄
Illustration by Nano Banana 2
Swift Compiler!
#expect(hand is Win) // ✅
खṛ Hand 14 Tiles
಄ ໘ࢠ Head Melds ྃ Winning Hand
ࠁࢠ ॱࢠ Identical Meld Sequential Meld
struct Hand< H: AnyPair, M1: AnyMeld, M2: AnyMeld, M3: AnyMeld,
M4: AnyMeld > {}
struct Pair< T1: TileType, T2: TileType >: AnyPair {} extension
Pair: ValidPair where T1 == T2 {} struct Meld< T1: TileType, T2: TileType, T3: TileType >: AnyMeld {}
None
ᤈ<1>
SE-0452 Integer Generic Parameters
struct Tile<Suit: SuitType, let rank: Int>: TileType {} typealias ᤈ<let
rank: Int> = Tile<ᤈࢠ, rank> typealias <let rank: Int> = Tile<ࢠ, rank> typealias ࡧ<let rank: Int> = Tile<ࡧࢠ, rank> ᤈ<1> ࡧ<4> <8> SE-0452 Integer Generic Parameters
extension Meld: ValidMeld where T1 == T2, T2 == T3
{}
#Playground { let identicalMeld = Meld<ᤈ<2>, ᤈ<2>, ᤈ<2>>() identicalMeld is
ValidMeld } // ✅ true #Playground { let invalidMeld = Meld<ᤈ<2>, <2>, ᤈ<3>>() invalidMeld is ValidMeld } // ❌ false
extension Meld: ValidMeld where Suit1 == Suit2, Suit2 == Suit3,
rank1 + 1 == rank2, rank2 + 1 == rank3 {}
extension Meld: ValidMeld where Suit1 == Suit2, Suit2 == Suit3,
rank1 + 1 == rank2, rank2 + 1 == rank3 {}
https://github.com/swiftlang/swift-evolution/blob/main/proposals/0452-integer-generic-parameters.md#future-directions
protocol Rank { associatedtype Next: Rank } struct One: Rank
{ typealias Next = Two } struct Two: Rank { typealias Next = Three } …
protocol Rank { associatedtype Next: Rank } struct `1`: Rank
{ typealias Next = `2` } struct `2`: Rank { typealias Next = `3` } … ᤈ<`1`> SE-0451 Raw Identi fi ers
extension Meld: ValidMeld where T1.S == T2.S, T2.S == T3.S,
T1.R.Next == T2.R, T2.R.Next == T3.R {}
#Playground { let sequentialMeld = Meld<<`2`>, <`3`>, <`4`>>() sequentialMeld is
ValidMeld } // ✅ true
extension Hand: Win where H: ValidPair, M1: ValidMeld, M2: ValidMeld,
M3: ValidMeld, M4: ValidMeld {} #Playground { let hand = Hand< Pair<ᤈ<`1`>, ᤈ<`1`>>, Meld<ᤈ<`2`>, ᤈ<`3`>, ᤈ<`4`>>, Meld<<`5`>, <`6`>, <`7`>>, Meld<ࡧ<`3`>, ࡧ<`4`>, ࡧ<`5`>>, Meld<ࡧ<`7`>, ࡧ<`8`>, ࡧ<`9`>> >() hand is Win } // ✅ true
Union Type ࠁࢠ ॱࢠ type ValidMeld = IdenticalMeld | SequentialMeld
/// Identical Meld (ࠁࢠ) extension Meld: ValidMeld where T1 ==
T2, T2 == T3 {} /// Sequential Meld (ॱࢠ) extension Meld: ValidMeld where T1.S == T2.S, T2.S == T3.S, T1.R.Next == T2.R, T2.R.Next == T3.R {}
/// Identical Meld (ࠁࢠ) extension Meld: ValidMeld where T1 ==
T2, T2 == T3 {} /// Sequential Meld (ॱࢠ) extension Meld: ValidMeld where T1.S == T2.S, T2.S == T3.S, T1.R.Next == T2.R, T2.R.Next == T3.R {}
❌ ❌ Union Types Arithmetic computation Can’t express sequential numbers
with Integer Generics Parameters Can’t conform a protocol both identical and sequential states Pure Swift Type System limitations
SE-0382 Expression Macros
#Playground { let result = #validate([ ࡧ<4>(), ࡧ<4>(), ᤈ<2>(), ᤈ<3>(),
ᤈ<4>(), ᤈ<5>(), ᤈ<6>(), ᤈ<7>(), <3>(), <4>(), <5>(), ࡧ<6>(), ࡧ<7>(), ࡧ<8>() ]) result is Win } // ✅ true
@freestanding(expression) public macro validate(_ tiles: [14 of any Tile]) ->
any Win = #externalMacro(module: "MacroValidatorMacros", type: "ValidateMacro") SE-0483 InlineArray Type Sugar SE-0382 Expression Macros
let win = #validate([ ࡧ<4>(), ࡧ<4>(), ᤈ<2>(), ᤈ<3>(), ᤈ<4>(), ᤈ<5>(),
ᤈ<6>(), ᤈ<7>(), <3>(), <4>(), <5>(), ࡧ<6>(), ࡧ<7>(), ࡧ<8>() ]) win is அϠΦ win is ฏ win is ରʑ // ✅ true // ✅ true // ❌ false
✅ ✅ Winning Pattern detection Automatic Head/Meld grouping Macro can
automatically group 14 tiles into head/melds Macro can detect Winning Patterns () Expression Macros
Conclusion • Pure Swift Type System is powerful, but limited
• Impossible to express complex game logics • Swift Macro is the Silver Bullet • Can represent the complex logic in the compilation time calculation
@giginet Thank you! https://mj-king.net/sozai/ Mahjong Tile Materials