SOLID Principles Equivalent in Functional Programming

design-patternsfunctional programmingsolid

I've found the SOLID principles quite useful when thinking about object-oriented design.

Is there a similar / equivalent set of language-agnostic principles tailored for functional programming?

Best Answer

It is a bit difficult to find equivalents but I can try:

  • S (SRP) in FP a function creates ALWAYS the same output for the same arguments this is called referential transparency
  • O (OCP) in FP there is a concept called algebraic data types, have a look how it relates to Class hierarchies and what problem both try to solve 1
  • L (LSP) Liskov Substitution Principle is Contravariance 2
  • D (DIP) in general functional programming achieves abstraction through function composition, there are also other mechanism with the help of category theory(for example monoid or functor), for "Dependency Injection" 3
Related Topic