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
giginet
PRO
April 14, 2026
Technology
420
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
330
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
Choose your own adventure in agentic design patterns
glaforge
0
160
20260428_Product Management Summit_Loglass_JoeHirose
loglassjoe
3
4k
巨大プラットフォームを進化させる「第3のROI」
recruitengineers
PRO
2
1.4k
AIでAIをテストする - 音声AIエージェントの品質保証戦略
morix1500
1
150
Arcana: Production-Ready RAG in Elixir @ ElixirConf EU 2026
georgeguimaraes
0
120
LLM時代の検索アーキテクチャと技術的意思決定
shibuiwilliam
3
1.5k
【技術書典20】OpenFOAM(自宅で深める流体解析)流れと熱移動(2)
kamakiri1225
0
270
ハーネスエンジニアリングをやりすぎた話 ~そのハーネスは解体された~
gotalab555
5
1.9k
Revisiting [CLS] and Patch Token Interaction in Vision Transformers
yu4u
0
400
はじめての MagicPod生成AI機能 機能紹介から活用方法まで
magicpod
0
120
基盤を育てる 外部SaaS連携の運用
gamonges_dresscode
1
120
AWS Agent Registry の基礎・概要を理解する/aws-agent-registry-intro
ren8k
3
410
Featured
See All Featured
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
680
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
340
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
160
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.4k
Agile that works and the tools we love
rasmusluckow
331
21k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
Bash Introduction
62gerente
615
210k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
220
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
210
The Language of Interfaces
destraynor
162
26k
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