Understanding why Zipper is a Comonad

前端 未结 1 1156
遇见更好的自我
遇见更好的自我 2021-02-01 11:44

This is a follow-up to the answer to my previous question.

Suppose I need to map each item a:A of List[A] to b:B with function

1条回答
  •  广开言路
    2021-02-01 12:05

    As this question is popping up regularly in the top of the "unanswered" list, let me just copy my comment as an answer here - nothing considerably more constructive has appeared since a year ago anyway.

    A List can be viewed as a comonad just as well (in multiple ways), while a Zipper can be cast as a monad (also in many ways). The difference is in whether you are conceptually focused on "appending" data constructively to a state machine (that's what the Monad interface is about), or "extracting" state from it "deconstructively" (that's what the Comonad does).

    It is not easy to answer the question, stated as "does this understanding make sense", however. In some sense it does, in another it does not.

    0 讨论(0)
提交回复
热议问题