Tech
ADTs & Enums in Scala 3: Making Illegal States a Compile Error
ADTs & Enums in Scala 3
If you've worked on enough business software, you've probably seen this:
final case class Order (
status : String ,
paidAt : Option [ Instant ],
shippedAt : Option [ Instant ],
cancelReason : Option [ String ]
)
It looks harmless.
Until you realize that this type allows all of these:
Order ( "pending" , Some ( now ), None , Some ( "customer changed their mind" ))
Order...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to