ekmett / ekmett/comonad

Select is a Comonad. Is SelectT?

Open
#63 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
79
Forks
31
PR merge metrics
No merged PRs in 30d

Description

I can write an instance of `Comonad` for `Select r`:

```haskell
instance Monoid r => Comonad (SelectT r Identity) where
extract s = runSelect s (const mempty)

extend f s = select $ \pb -> f $ select $ \pa -> runSelect s $ \a -> mappend (pa a) (pb $ f $ pure a)
```

I'm pretty sure it's conforming, though I haven't done all the juggling to verify the composition works. My question now is what additional conditions on `m` are needed to ensure that `SelectT r m` is a `Comonad`?

EDIT: I [verified the Comonad laws and one of the ComonadApply ones](https://gist.github.com/Zemyla/9bb6440c6b180fa47c775d836be18bd3). However, `duplicate (sf <*> sa) = liftA2 (<*>) (duplicate sf) (duplicate sa)` may actually kill me.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked law-checking gist and the existing definitions of Select and SelectT. Work through the remaining Comonad and ComonadApply laws, especially the duplicate law mentioned in the edit. Done means identifying and documenting the conditions on m, or showing that the proposed instance cannot satisfy the laws.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.