Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
20250116 関数型DDD 2
Search
saka
December 24, 2025
11
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
20250116 関数型DDD 2
saka
December 24, 2025
More Decks by saka
See All by saka
20250304 関数型DDD 6
sakatttttta
0
25
20241219 Github Actionsの面倒いところ
sakatttttta
0
18
20250109 関数型
sakatttttta
0
11
20250123 関数型DDD 3
sakatttttta
0
11
20250206 関数型DDD 4
sakatttttta
0
12
20250213 関数型DDD 4
sakatttttta
0
12
20250220 Hono カスタムfetch
sakatttttta
0
10
20250225 関数型DDD 5
sakatttttta
0
9
20250311 関数型DDD 7
sakatttttta
0
9
Featured
See All Featured
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
How STYLIGHT went responsive
nonsquared
100
6.3k
The browser strikes back
jonoalderson
0
1.8k
Site-Speed That Sticks
csswizardry
13
1.6k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Leo the Paperboy
mayatellez
10
2.4k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
600
The SEO identity crisis: Don't let AI make you average
varn
0
590
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Mobile First: as difficult as doing things right
swwweet
225
10k
Raft: Consensus for Rubyists
vanstee
142
7.8k
Transcript
ؔܕDDD 2
લճ
ίϯύΠϧ=ςετ
ؔ
δΣωϦοΫܕ
ܕͷ߹
type Sample = { | a: ٻ৬ऀͷform; | b: ࠾༻୲ͷform;
};
ଓ͖
୯७ܕ
બࢶ͕Ұ͔ͭ͠ͳ͍
type ProductCode = | ProductCode of string
type ProductCode = ProductCode of string
TypeScript
type ProductCode = string; ܕ҆શΫιͳ͍
ύλʔϯ2 ϒϥϯυܕ
ͷલʹ
TypeScriptͷܕʹ͍ͭͯ
type UserId = string; type ItemId = string;
͜ΕҰॹͷܕͱͯ͠ ѻΘΕΔ
ߏ͕ҰॹͳΒ ΤϥʔͰͳ͍
None
None
type Test = string & { __brand: Teee }
͜ΕͰผͷܕʹͳΔ
type ProductCode = string & { readonly __brand: unique symbol
};
type ProductCode = string & { readonly __brand: unique symbol
}; type SubCode = string & { readonly __brand: unique symbol }; const product: ProductCode = "ABC123" as ProductCode; const sub: SubCode = "DEF456" as SubCode; // Τϥʔ͕ൃੜ const productSub: ProductCode = sub;
جຊతʹ͜ΕstringͳͷͰ ϥϯλΠϜͰΤϥʔͳ͠
ϒϥϯυܕ ίϯύΠϧ࣌ɿΤϥʔ ϥϯλΠϜɿΤϥʔͰͳ͍
ύλʔϯ3
type ProductCode = { Type: "ProductCode"; value: string; };
ίϯύΠϧ࣌ɿΤϥʔ ϥϯλΠϜɿΤϥʔ
ܕ͝ͱʹॲཧΛ͚͍ͨ
function handleCode(code: ProductCode | SubCode) { if (code.tag === "ProductCode")
{ console.log("ProductCode: " + code.value); } else if (code.tag === "SubCode") { console.log("SubCode: " + code.value); } }
Ͳ͕͍͍ͬͪͷ͔