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
130
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
Oracle Cloud Infrastructure(OCI):Onboarding Session(はじめてのOCI/Oracle Supportご利⽤ガイド)
oracle4engineer
PRO
2
17k
スクラムを支える内部品質の話
iij_pr
0
320
Babylon.js Japan Activities (2026/4)
limes2018
0
190
チームで育てるAI自走環境_20260409
fuktig
0
930
AI時代に新卒採用、はじめました/junior-engineer-never-die
dmnlk
0
200
ZOZOTOWNリプレイスでのSkills導入までの流れとこれから
zozotech
PRO
4
3k
ある製造業の会社全体のAI化に1エンジニアが挑んだ話
kitami
2
160
Hello UUID
mimifuwacc
0
120
自己組織化を試される緑茶ハイを求めて、今日も全力であそんで学ぼう / Self-Organization and Shochu Green Tea
naitosatoshi
0
280
「できない」のアウトプット 同人誌『精神を壊してからの』シリーズ出版を 通して得られたこと
comi190327
3
620
組織的なAI活用を阻む 最大のハードルは コンテキストデザインだった
ixbox
1
1.1k
AWSで2番目にリリースされたサービスについてお話しします(諸説あります)
yama3133
0
130
Featured
See All Featured
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
350
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
160
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
130
Documentation Writing (for coders)
carmenintech
77
5.3k
How to build a perfect <img>
jonoalderson
1
5.3k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
160
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
200
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
170
The Language of Interfaces
destraynor
162
26k
From π to Pie charts
rasagy
0
160
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
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