[Haskell-beginners] Extend instance for List

Kim-Ee Yeoh ky3 at atamo.com
Tue Dec 15 10:36:58 UTC 2015


On Tue, Dec 15, 2015 at 12:43 AM, Graham Gill <math.simplex at gmail.com>
wrote:

I guessed that the correct Extend instance for List is needed for Comonad,
> but didn't have any intuition about it.
>

List is not comonadic. In this case, the function copure must be of type
[a] -> a, which must necessarily be partial.

(Non-empty lists, on the other hand, are comonadic.)

Graham's "Extend" -- I'll explain the scare quotes in a minute -- instance
for List obeys the associative law. So it's a valid instance but a bit
boring. The exercise asks for an interesting instance.

The way the NICTA course is structured, there's no mention of the
> dependence between "extend" and "copure" (equivalent to extract and
> duplicate I suppose) via the Comonad laws when considering Extend first by
> itself.
>

It's a bit terse, but you can find "class Extend f => Comonad f" in
Comonad.hs. After all, we're only looking at the exercises. The live
lecture version probably does talk about the dependence.


> I'm not knocking the NICTA course. I've found it useful. A quick paragraph
> or two as you've written, stuck into the source files as comments, would
> improve it.
>

Most folks are neutral about the course. If parts of it work for you,
great. If not, no worries. The whole comonadic business is a bit obscure
and some of the strongest haskell programmers don't bat an eyelid over not
knowing it.

p.s. "Extend" doesn't agree with the CT literature. See the paragraph that
starts "The dual problem is the problem of lifting a morphism" here:

http://ncatlab.org/nlab/show/extension

But calling it a "lift" or "lifting" will only add to the confusion since
monad transformers got first dibs on the terminology. Which is why you
sometimes see "coextend" or (for the flipped version) "cobind".


-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151215/752d4736/attachment-0001.html>


More information about the Beginners mailing list