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
20250116 関数型DDD 2
Search
saka
December 24, 2025
4
0
Share
20250116 関数型DDD 2
saka
December 24, 2025
More Decks by saka
See All by saka
20250304 関数型DDD 6
sakatttttta
0
17
20241219 Github Actionsの面倒いところ
sakatttttta
0
3
20250109 関数型
sakatttttta
0
3
20250123 関数型DDD 3
sakatttttta
0
2
20250206 関数型DDD 4
sakatttttta
0
1
20250213 関数型DDD 4
sakatttttta
0
2
20250220 Hono カスタムfetch
sakatttttta
0
1
20250225 関数型DDD 5
sakatttttta
0
1
20250311 関数型DDD 7
sakatttttta
0
2
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
AI: The stuff that nobody shows you
jnunemaker
PRO
4
510
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
It's Worth the Effort
3n
188
29k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
470
The Curse of the Amulet
leimatthew05
1
11k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
330
Practical Orchestrator
shlominoach
191
11k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
260
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
280
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); } }
Ͳ͕͍͍ͬͪͷ͔