Dear Marc, Thanks for your explanation. I re-explain below to ensure my understanding is correct.
> (The type of finite lists does not form an initial coalgebra so the > notion of anamorphism does not really apply.) You mean "final coalgebra" rather than "initial coalgebra", right? Given a functor F(S)=1+N×S, the carry object of the final coalgebra for F is List(T)∪Stream(T), where T is the type of the elements. The set List(T)∪Stream(T) can not be expressed by lists in Scheme, because lists in Scheme are finite and Scheme is a strict language. So the notion of anamorphism does not really apply. (But it is OK in Haskell) > If we could define a `reverse` for infinite lists, we could explain `unfold-right`. So this is why Scheme has `unfold-right` and Haskell has not `unfold-right`, is that right? Because lists in Haskell are potentially infinite, we can not define a `reverse` for these infinite lists. (But it is OK in Scheme) > But why can't we define a `reverse' for infinite lists? This is basically because the cartesian product has a right adjoint (the exponential) in our cases but not a left adjoint. (Do you see what I mean?) I have a little background in category theory. I know - × a ⊣ (-)ᵃ. This formula sometimes expresses currying, but what does it mean here? Could you give me some hints? > We could only circumvent this restriction by changing our underlying model and allowing computations that take infinitely long ... This exactly Haskell do. > In order to make sense of the right version in the context of coinitial coalgebras, a naive way to incorporate them is through double-ended streams. So the rest of your mail is to explain how to implement `unfold-right` in Haskell, right? We will use two left/right symmetry lists to express a reversible list. > The endofunctor G underlying a double-ended stream whose elements are of type T would be X |-> 1 + (T * X * T * X) So the mathematical name behind "unfold-right" is G-coalgebra, is that right? > We could then unfold any G-coalgebra into a double-ended stream (the coinitial coalgebra of G); That means `unfold-right` can be generalized to other data types by G-coalgebra and thisis the answer to my second question, right? Could you recommend some references about this `unfold-right` stuff or G-coalgebra? For example, is there any Haskell library implement `unfold-right` or G-coalgebra? Or any papers explain this stuff in more detail? Thanks again. PS: Sorry for the late reply. It seems that the [email protected] doesn't send any mail except daily digest. I did not receive any mails until daily digest. I even I can't see your email address. So this mail may not be merged into the reply-tree. I have re-subscribed [email protected] and [email protected] instead. Best regards, Siyuan Chen
