## Archive for July, 2007

### Decisive Functors

Sunday, July 8th, 2007 by Conor

It’s another name-choosing exercise that I’m vacillating about, but here’s today’s terminology for the dual to Applicative functors. Remember we had the lax monoidal presentation

Well, switch from products to coproducts and flip round those arrows and you’ve got

A Decisive f gives us some sort of certainty with respect to its parameter. If you think of f as some sort of epistemic modality, then it’s quite a useful one. Firstly, if we know/believe/imagine Zero, that must mean the world really is no good, and there really is an element of Zero. Even better, if we know/believe/imagine S or T, that must mean we actually know/believe/imagine S or know/believe/imagine T. ‘Or’ behaves well, and always gives us a decision.

I wonder what we expect to hold. Well, naturally,

but surely we’d also like

where

but we’d also hope for

I wonder what else.

There’s an ‘idiomatic’ interface to these things.

Now, guess what. Every comonad is decisive. As it were,

That is, orwell revises the story so that, throughout, it’s consistently on whichever side we happen to be on at the (counit) moment.

Sunday, July 8th, 2007 by Conor

Lists are applicative with a zipping-truncating behaviour, but these guys (written backwards, today)

are applicative with a zipping-padding behaviour. Like this

They're also happily monadic in the nondeterministic sense. Moreover, the join

is structurally recursive (if you know what you're doing) and structurally corecursive, unlike the obvious candidate for join on CoList.

So these guys, as data or codata, get to be monadic hence applicative, but also (and differently) zip-max applicative. The padding behaviour is useful for making rectangular text boxes.

Note that Paddy is not Alternative because, like Ernst Stavro Blofeld, he doesn't tolerate failure.

That's to say, thinking of these things temporally, each entry in the output to a cobind at a given time is given by the history of the input up to that time. Computations can't do more, but they can be more, by being in context. Again, note productivity means the codata version is also comonadic.

Reminder: lists, colists, etc are not instances of the free/completely iterative monad/comonad construction, as they have node information rather than leaf information, and are additive. Amusing, then, that they are so well behaved.

### Composing Applicative and Alternative

Sunday, July 8th, 2007 by Conor

Nicolas asked whether the composition (either way around) of an Applicative functor

and an Alternative functor

was necessarily Alternative (of course, both f⋅g and g⋅f are Applicative). The answer is yes, both are Alternative. Firstly, g⋅f is Alternative, just by specialising g’s operations. Secondly, f⋅g is Alternative just by the usual idiomatic f-lifting of g’s operations. The applicative functor laws guarantee that the f-effects are combined associatively.

In the hunt for interesting non-monadic examples, we were drawn once again to

These things are not monadic like lists-with-‘nondeterminism’: the join
is not productive (what should do? These things are not monadic like streams-with-‘diagonal’ (raggedness breaks associativity of joining). But they are Applicative in the ‘minimum-diagonal’ sense

They are also alternative