The inverse of a monad. A monad is a way to structure computations in terms of values and sequences of computations using those values. Monads allow the programmer to build up computations using sequential building blocks, which can themselves be sequences of computations.
Questions tagged [comonad]
63 questions
3
votes
1 answer
Performance of Conway's Game of Life using the Store comonad
I've written a simple implementation of Conway's Game of Life using the Store comonad (see code below). My problem is that the grid generation is getting visibly slower from the fifth iteration onwards. Is my issue related to the fact that I'm using…

Dan Oneață
- 968
- 7
- 14
3
votes
1 answer
Using Comonad Fix Combinators
So I've been experimenting with fixed points lately and have finally struggled
through regular fixed points enough to discover some uses; now I'm moving onto
comonadic fixed points and I'm afraid I've gotten stuck;
Here's a few examples of what I've…

Chris Penner
- 1,881
- 11
- 15
3
votes
0 answers
Does a natural monoidal structure on copoints of a Functor induce a Comonad?
The situation is as follows (I changed to more standard-ish Haskell notation):
class Functor f => MonoidallyCopointed f where
copointAppend :: (∀r.f(r)->r) -> (∀r.f(r)->r) -> (∀r.f(r)->r)
copointEmpty :: ∀r.f(r)->r
such that for all…

mnish
- 385
- 2
- 11
3
votes
2 answers
Tie-the-knot in 2 dimensions (was: tying the knot with a comonad)
Edit: The original question was "tying the knot with a comonad", but what really helped here is a two-dimensional knot tying with U2Graph from cirdec. Original question (until Anwser):
I want to tie the knot with data that originates from a…

Franky
- 2,339
- 2
- 18
- 27
2
votes
1 answer
Can someone explain how the cofree comonad is "similar to" Halogen?
In the paper Declarative UIs are the future -- and the future is comonadic by Phil Friedman, he makes the claim, when introducing the cofree comonad that:
...this approach is reminiscent of the approach taken in the Halogen user interface…

Nathan BeDell
- 2,263
- 1
- 14
- 25
2
votes
0 answers
What is the point of the `Store` comonad if recovering a container is difficult?
A pointed container is a comonad, and this observation can be used to obtain some useful effects, like for example stencil convolutions, almost for free. Further it is noticed that an instance Comonad may be obtained in a standard way via the Store…

Ignat Insarov
- 4,660
- 18
- 37
2
votes
1 answer
What is the difference between the Store Comonad and a Representable Store Comonad in functional programming?
The Representable Store Comonad and the Store Comonad offers similar features... When should we use one over the other, and what are the benefits?

Valy Dia
- 2,781
- 2
- 12
- 32
2
votes
3 answers
Haskell's (<-) in Terms of the Natural Transformations of Monad
So I'm playing around with the hasbolt module in GHCi and I had a curiosity about some desugaring. I've been connecting to a Neo4j database by creating a pipe as follows
ghci> pipe <- connect $ def {credentials}
and that works just fine. However,…

Tshimanga
- 845
- 6
- 16
2
votes
1 answer
Pithy summary for codata (Where a comonad is a 'type for input impurity')
In terms of pithy summaries - this description of Comonads seems to win - describing them as a 'type for input impurity'.
What is an equivalent pithy (one-sentence) description for codata?

hawkeye
- 34,745
- 30
- 150
- 304
1
vote
2 answers
Agda Store Comonad
I'm just starting with Agda but know some Haskell and would like to know how to define the Store Comonad in Agda.
This is what I have until now:
open import Category.Comonad
open import Data.Product
Store : Set → Set → ((Set → Set) × Set)
…

fsuna064
- 195
- 1
- 7
1
vote
1 answer
How to combine a comonad and a monad into a comonad?
Assume I have
a comonad D
a monad T
a distributive law l : D T -> T D of the comonad D over the monad T.
How can I define the comonad D T?

Bob
- 1,713
- 10
- 23
1
vote
1 answer
Random walk on a pointed container
Let us consider a dwarf wandering in a tunnel. I will define a type that represents this
situation thusly:
data X a = X { xs :: [a], i :: Int }
display :: X Bool -> IO ()
display X{..} = putStrLn (concatMap f xs) where { f True = "*" ; f False =…

Ignat Insarov
- 4,660
- 18
- 37
1
vote
2 answers
Cannot find a functor instance for Tuple2K
I have a toy DSL
case class Logging[A](msg: String, action: A)
case class Persist[A](msg: String, action: A)
type Effect[A] = EitherK[Logging, Persist, A]
that I want to pair with an equally toy interpreter
case class CoLogging[A](run: String =>…

Regis Kuckaertz
- 991
- 5
- 14
1
vote
1 answer
Type Variable Location in Transformers
Consider the State type - or at least a simplified version:
newtype State s a = State { runState :: s -> (a, s) }
Now, let's say we want to derive the StateT monad transformer. transformers defines it as follows:
newtype StateT s m a = StateT {…

bradrn
- 8,337
- 2
- 22
- 51
1
vote
0 answers
Mutate only focus of Store Comonad?
I'm using Control.Comonad.Representable.Store to represent a grid object for a game; the grid is: type Grid = Store (Compose Vector Vector) a; where Vector has a representable instance indexed by Int.
This allows me to use comonadic extend and…

Chris Penner
- 1,881
- 11
- 15