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
20250213 関数型DDD 4
Search
saka
December 24, 2025
2
0
Share
20250213 関数型DDD 4
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
20250116 関数型DDD 2
sakatttttta
0
4
20250123 関数型DDD 3
sakatttttta
0
2
20250206 関数型DDD 4
sakatttttta
0
1
20250220 Hono カスタムfetch
sakatttttta
0
1
20250225 関数型DDD 5
sakatttttta
0
1
20250311 関数型DDD 7
sakatttttta
0
2
Featured
See All Featured
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
500
Done Done
chrislema
186
16k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
210
Code Reviewing Like a Champion
maltzj
528
40k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
99
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.2k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Writing Fast Ruby
sferik
630
63k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
120
4 Signs Your Business is Dying
shpigford
187
22k
Transcript
ؔܕDDD
લճ
ೖग़ྗ͕ෳ
type PlaceOrderEvents = { AcknowledgmentSent : AcknowledgmentSent OrderPlaced : OrderPlaced
BillableOrderPlaced : BillableOrderPlaced } type PlaceOrder = UnvalidatedOrder -> PlaceOrderE
type CategorizedMail = | Quote of QuoteForm | Order of
OrderForm // etc type CategorizeInboundMail = EnvelopeContents -> CategorizedMail
ResultͳͲ·ͱΊ
type ValidationResponse<'a> = Async<Result<'a, ValidationError list>> type ValidateOrder = UnvalidatedOrder
-> Async<Result<ValidatedOrder, ValidationError list>> type ValidateOrder = UnvalidatedOrder -> ValidationResponse<ValidatedOrder>
None
࠷ॳݸผ ޙύΠϓϥΠϯ
ੑ εΩοϓ
ෆมੑ
લʑճͷεϥΠυΑΓ
ঢ়ଶมԽ
ू εΩοϓ
ΦϒδΣΫτͷ࡞ ߟ͑தεΩοϓ
ෆม݅
ඞͣ໌ࡉ͕ ଘࡏ͠ͳ͚Ε͍͚ͳ͍
͜ΕܕͰ
type NonEmptyList<'a> = { First : 'a Rest : 'a
list }
ύΠϓϥΠϯʹ ͍ͯ͜͠͏
ϞσϧԽ͢Δͭ
None
ঢ়ଶͷભҠʹ
None
Ͳ͏Δʁ
ͦΕͧΕͷঢ়ଶͷܕΛ࡞ Δ
type PricedOrder = { OrderId : ... CustomerInfo : CustomerInfo
ShippingAddress : Address BillingAddress : Address // ݕূࡁΈͷจ໌ࡉߦͱҟͳΔ OrderLines : PricedOrderLine list AmountToBill : BillingAmount }
τοϓϨϕϧͰ߹
type Order = | Unvalidated of UnvalidatedOrder | Validated of
ValidatedOrder | Priced of PricedOrder // etc
͜ΕΒͷભҠͲ͏͢ Δʁ
εςʔτϚγϯ
None
ͳͥ͏ͷ͔
• ͦΕͧΕͷঢ়ଶͰडΕΔॲཧΛม͑ΒΕΔ • શͯͷঢ়ଶΛ໌ࣔతʹͰ͖Δ • ى͜Γ͏Δঢ়گΛશͯߟྀʹೖΕΔͱ͍͏ࢥߟ͕ಇ͖͍͢
F#αϯϓϧ
·ͣܕ
type ShoppingCart = | EmptyCart // σʔλແ͠ | ActiveCart of
ActiveCartData | PaidCart of PaidCartData
εςʔτϚγϯ
let addItem cart item = match cart with | EmptyCart
-> // ࢦఆ͞ΕͨΞΠςϜͰɺ৽͍͠ΞΫςΟϒͳΧʔτΛ࡞ ActiveCart { UnpaidItems = [item] } | ActiveCart { UnpaidItems = existingItems } -> // ࢦఆ͞ΕͨΞΠςϜͱՃࡁΈͷΞΠςϜͰɺ৽͍͠ΞΫςΟϒͳΧʔτΛ࡞ ActiveCart { UnpaidItems = item :: existingItems } | PaidCart _ -> // ແࢹ cart
TSʢGPT༷ʣ
None
৽͍͠Χʔτͷฦ͠ํʹෆຬ ͋Δ͚Ͳ·͋͜Μͳײ͡ʁ