4 ms·
This link offers three examples: http://www.haskellforall.com/2013/02/you-could-have-invented-comonads.html http://www.haskellforall.com/2013/02/you-could-have-
by danidiaz 13y ago
This link offers three examples: http://www.haskellforall.com/2013/02/you-could-have-invented-comonads.html http://www.haskellforall.com/2013/02/you-could-have-invented... (altough I find the object analogy to be unhelpful.)
I think the more striking example is the first: "builders" with a default starting value form a comonad, which is the dual of the Writer monad. A Haskell implementation can be found in package 'comonad-transformers' as the 'Traced' comonad.
Infinite streams also form a comonad ('Data.Stream.Infinite' from the 'streams' package).