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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
giginet
PRO
April 14, 2026
Technology
430
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
340
Claude Codeログ基盤の構築
giginet
PRO
7
4.1k
Inside of Swift Export
giginet
PRO
1
2.3k
Swiftビルド弾丸ツアー - Swift Buildが作る新しいエコシステム
giginet
PRO
0
2.7k
SwiftでMCPサーバーを作ろう!
giginet
PRO
3
420
Creating Intuitive Developer Tool in Swift
giginet
PRO
0
1.5k
Mergeable Libraryで 高速なアプリ起動を実現しよう!
giginet
PRO
2
7.1k
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
M5Stack CoreS3とZephyr(RTOS)で Edge AIっぽいことしてみた
iotengineer22
0
390
アクセシビリティはすべての人のもの
tomokusaba
0
150
GitHub Copilot CLI と VS Code Agent Mode の使い分け
tomokusaba
0
110
『生成AI時代のクレデンシャルとパーミッション設計 — Claude Code を起点に』の執筆企画
takuros
1
1.5k
Chasing Real-Time Observability for CRuby
whitegreen
0
440
Google Cloud Next '26 の裏でこっそりリリースされたCloud Number Registry & Cloud Hub コスト分析 を試してみた
hikaru1001
0
120
Arcana: Production-Ready RAG in Elixir @ ElixirConf EU 2026
georgeguimaraes
0
120
PyCon JPに学ぶ『決め方の決め方』: TechLead Conference 2026
terapyon
1
280
ServiceNow Knowledge 26 の歩き方
manarobot
0
250
コミュニティ・勉強会を作るのは目的じゃない
ohmori_yusuke
0
280
基盤を育てる 外部SaaS連携の運用
gamonges_dresscode
1
120
「責任あるAIエージェント」こそ自社で開発しよう!
minorun365
10
2.6k
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
340
Facilitating Awesome Meetings
lara
57
6.8k
The Limits of Empathy - UXLibs8
cassininazir
1
310
Raft: Consensus for Rubyists
vanstee
141
7.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Unsuck your backbone
ammeep
672
58k
Fireside Chat
paigeccino
42
3.9k
Google's AI Overviews - The New Search
badams
0
990
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
160
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
500
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
750
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