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
20250206 関数型DDD 4
Search
saka
December 24, 2025
1
0
Share
20250206 関数型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
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
Building Adaptive Systems
keathley
44
3k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
860
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
140
Side Projects
sachag
455
43k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
160
Accessibility Awareness
sabderemane
0
91
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
250
Transcript
ؔܕଓ͖
લճ
type Option<'a> = | Some of 'a | None
type Result<'Success, 'Failure> = | Ok of 'Success | Error
of 'Failure
ܕʹΑΔ υϝΠϯϞσϦϯά
ܕΛίʔυԽ
// ----- ະݕূͷঢ়ଶ ----- data UnvalidatedOrder = UnvalidatedCustomerInfo AND UnvalidatedShippingAddress
AND UnvalidatedBillingAddress AND list of UnvalidatedOrderLine
work f low "Place Order" = input: UnvalidatedOrder output (on
success): OrderAcknowledgmentSent AND OrderPlaced (to send to shipping) AND BillableOrderPlaced (to send to billing) output (on error): InvalidOrder
جຊతͳߟ͑
// ܕΛఆٛ type CustomerId = CustomerId of int type OrderId
= OrderId of int // Λఆٛ let customerId = CustomerId 42 let orderId = OrderId 42 // CustomerIdΛ͏ؔΛఆٛ let processCustomerId (id: CustomerId) = ... // OrderIdΛ͢ͱ -- ίϯύΠϥʔΤϥʔʂ processCustomerId orderId
None
None
ϫʔΫϑϩʔ
type ValidateOrder = UnvalidatedOrder -> ValidatedOrder
ग़ྗೖྗ͕ෳࡶͳ߹
ೖग़ྗ͕ෳ
type PlaceOrderEvents = { AcknowledgmentSent : AcknowledgmentSent OrderPlaced : OrderPlaced
BillableOrderPlaced : BillableOrderPlaced } type PlaceOrder = UnvalidatedOrder -> PlaceOrderEvents
ೖग़ྗ͕Ͳ͔ͬͪ
type CategorizedMail = | Quote of QuoteForm | Order of
OrderForm // etc type CategorizeInboundMail = EnvelopeContents -> CategorizedMail
ΤϥʔΛฦ͢Մೳੑ
type ValidateOrder = UnvalidatedOrder -> ValidatedOrder type ValidateOrder = (unvalidatedOrder:
UnvalidatedOrder) => ValidatedOrder;
type ValidateOrder = UnvalidatedOrder -> Result<ValidatedOrder, ValidationError list> and ValidationError
= { FieldName : string ErrorDescription : string }
͞Βʹඇಉظ
type ValidationResponse<'a> = Async<Result<'a, ValidationError list>> type ValidateOrder = UnvalidatedOrder
-> Async<Result<ValidatedOrder, ValidationError list>> type ValidateOrder = UnvalidatedOrder -> ValidationResponse<ValidatedOrder>
None