Peter G. Hancock
27 Dec 2002 17:36:33 +0000
I came across an interesting paper "Codata and comonads in Haskell" by
Richard Kieburtz, and some other work by Alberto Pardo on comonads.
Kieburtz proposes an OI comonad, as an alternative to (or something
alongside?) the IO monad. Just for reasons of symmetry, it's natural
to wonder if they aren't as pervasive in functional programs as
Frustratingly, I can't seem to grasp the intuition. I'm aware that
the state-monad s->(s,a) has a dual state-in-context
comonad (s,s->a). How does the side-effect manifest itself?
The (ineffective) hints the authors give revolve around the idea that
side-effects "derive" from the context of a program. Any other hints?
Are comonads especially appropriate for programming systems that react
to changes in their environment? Is an object of OI type something like
a program to react to events?
I can't make the slightest sense of Kieburtz's OI co-monad, with
commands like coGetChar :: OI Handle -> Char.