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
450
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
350
Claude Codeログ基盤の構築
giginet
PRO
7
4.2k
Inside of Swift Export
giginet
PRO
1
2.4k
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.3k
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
Agent Skillsで実現する記憶領域の運用とその後
yamadashy
2
1.5k
会社説明資料|株式会社ギークプラス ソフトウェア事業部
geekplus_tech
0
210
Agent の「自由」と「安全」〜未来に向けて今できること〜
katayan
0
350
Oracle Cloud Infrastructure presents managed, serverless MCP Servers for Oracle AI Database
thatjeffsmith
0
170
Digital Independence: Why, When and How
wannesrams
0
300
拝啓、あの夏の僕へ〜あなたも知っているApp Runnerの世界〜
news_it_enj
0
220
データモデリング通り #5オンライン勉強会: AIに『ビジネスの文脈』を教え込むデータモデリング
datayokocho
0
190
サンプリングは「作る」のか「使う」のか? 分散トレースのコストと運用を両立する実践的戦略 / Why you need the tail sampling and why you don't want it
ymotongpoo
3
130
Building Production-Ready Agents Microsoft Agent Framework
_mertmetin
0
160
色を視る
yuzneri
0
330
MySQL 9.7がやってきた ~これまでのあらすじと基本情報~ @ 日本MySQLユーザ会会2026年04月 / mysql97-yattekita
sakaik
0
180
2026-05-14 要件定義からソース管理まで!IBM Bob基礎ハンズオン
yutanonaka
0
110
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
240
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
110
Designing for humans not robots
tammielis
254
26k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
230
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Crafting Experiences
bethany
1
140
Bash Introduction
62gerente
615
210k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
How to Talk to Developers About Accessibility
jct
2
190
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