Functional equivalent of decorator pattern?

后端 未结 10 2208
悲&欢浪女
悲&欢浪女 2021-02-02 06:34

What is the functional programming equivalent of the decorator design pattern?

For example, how would you write this particular example in a functional style?

10条回答
  •  猫巷女王i
    2021-02-02 07:18

    The Joy of Clojure talks about this very issue in chapter 13.3, "A lack of design patterns". According to the JoC, the -> and ->> macros are somewhat analogous to the decorator pattern.

提交回复
热议问题