Lambda the Ultimate

inactiveTopic Codata and Comonads in Haskell
started 8/13/2003; 5:30:09 AM - last post 8/19/2003; 4:20:41 AM
Ehud Lamm - Codata and Comonads in Haskell  blueArrow
8/13/2003; 5:30:09 AM (reads: 2273, responses: 2)
Codata and Comonads in Haskell
Codata and Comonads in Haskell. Richard B. Kieburtz

This paper suggests that a useful interpretation of comonads in programming is that they account for effects originating in the context of a program fragment, effects to which the program fragment may react and which it may further propagate.

I cam across this paper browsing the Haskell Wiki, and it looks pretty interesting.

I am not sure I fully grasp the utility of comonads, but maybe someone more knowledgeable will care to comment.

Editors, we need to post some non-FP links quickly!


Posted to functional by Ehud Lamm on 8/13/03; 5:32:35 AM

Pseudonym - Re: Codata and Comonads in Haskell  blueArrow
8/17/2003; 6:07:12 PM (reads: 450, responses: 0)

Codata is a very powerful idea, and it's used (partly unknowingly) in a lot of APIs, both declarative and non-declarative. Take, for example, the Java Iterator object:

interface Iterator {
    public boolean hasNext();
    public Object next();
};

(It's been a while since I used any Java. Sorry if I got the syntax wrong.)

This is an implementation of the coalgebraic formulation of (possibly infinite) streams:

<A_inf, f: A_inf -> 1 + (A x A_inf)>

On comonads, though, note this thread from the Haskell mailing list. We still don't know if comonads break referential transparency without some kind of linear type constraint or not.

Dave Herman - Re: Codata and Comonads in Haskell  blueArrow
8/19/2003; 4:20:41 AM (reads: 418, responses: 0)
Am I going cross-eyed or is there a typo on page 5 in the definition of the State comonad? He defines co-ext as:

co-ext f = (λ(g, s) → (λs′f (g, s′)), s)

but I think it should be:

co-ext f = λ(g, s) → (λs′f (g, s′), s)