Remix.run Logo
kristianp 6 days ago

And on the other end of the spectrum, you have the proponents of Domain-driven design (DDD)[0], where they use an ML descended language such as F# and the aim is to make invalid states unrepresentable by the program [1]

[0] https://fsharpforfunandprofit.com/ddd/

[1] Make invalid states unrepresentable: https://geeklaunch.io/blog/make-invalid-states-unrepresentab...

zozbot234 6 days ago | parent | next [-]

How is this "the other end of the spectrum"? The Typestate pattern described at https://geeklaunch.io/blog/make-invalid-states-unrepresentab... (especially wrt. its genericized variety that's quite commonly used in Rust) is precisely a "compile-time hierarchy of encapsulation that matches the domain model", to use Casey Muratori's term for what he's talking about. It's literally inheritance-based OOP in a trenchcoat.

kristianp 4 days ago | parent [-]

I mean the opposite of Casey's viewpoint that it's a mistake.

jbreckmckye 6 days ago | parent | prev [-]

There is a good book on DDD in F#, Domain Modelling Made Functional

HexDecOctBin 6 days ago | parent | next [-]

Is there a similar recommended book using ML/OCaml or some other language of the family? i am hesitant to learn F#, knowing Microsoft's tendencies.

S04dKHzrKT 6 days ago | parent [-]

There are very few F# specific features used in the book. I imagine you could follow along pretty easily with any other functional language. You can easily use F# for the book and then apply the lessons learned to another language when you're done too. It mainly shows how to use sum types, product types and function composition to implement DDD.

I'm not sure what tendencies you're referring to though. F# has been around for 20 years and has only gotten better over time.

clickety_clack 6 days ago | parent | prev [-]

Yes! I just got a copy of this a couple of days ago. Ive been on a DDD + FP kick recently and it’s leading to some really satisfying solutions.