I've been using applicative (and alternative) a fair bit lately, and one thing that has been frustrating me is my lack of knowledge of the nomenclature. As an example, I'd like to be able to say function name
instead of star thing
for <*>
. So, in much the same way that >>=
is read bind
, are there more human-friendly names for the following:
<*>
- apply?<*
& *>
- left and right apply?<$>
- fmap?<|>
and likewise from arrows
***
- split?&&&
- fanout?If there are names for these, my searches haven't uncovered them. I understand that there might not be accepted terms for these, but if there are I'd love to know them.
The notation comes from Doaitse Swierstra and Luc Duponcheel: they had already identified this interface for parser combinators, and we felt it was important to respect their choices where it was meaningful to do so. I'm trying to remember how Doaitse pronounces them, but drawing a blank.
I prefer them to be seen and not heard. In fact, I prefer them not to be seen either, hence idiom brackets. But especially when defining an instance, it's helpful to have names. Not that it's down to me to name them: the whole Idiom vs Applicative vs goodness-knows-what shenanigans was a fascinating study of power. For what it's worth, in my own parlance
<*>
is 'applied (to)' (the interface is 'pure and applied', like mathematics)*>
is 'ignored'<*
is 'ignoring'<$>
is 'mapped (over)'<$
is perhaps 'after', but I'm not terribly conscious of calling it anythingThe key ideas: the effects always sequence (whatever that means) left-to-right; the $ or * tell you whether what's to their left is pure or idiomatic; the chevrons tell you the resulting dataflow, pointing only to the signal.
An alternative pronunciation scheme, a level away from the individual operators, might translate
f <$> a <*> b <* c <*> d
to 'IDIOM: f, a, b, NOISE c, d' or some such. But that's really reading the bracket version
(|f a b (-c-) d|)
out loud.
I find 'money' and 'splat' amusing, but we might do well to prioritize semantics over asciidents of syntax.
Well, <$>
is a synonym for fmap
. Also, the name "applicative" makes me think of applying things. Since <*>
is the main operator for doing that, I think I associate it loosely with the word "apply". The context is slightly different from normal function application so there could be some confusion with that word, but the context usually makes it clear enough, so it works for me. <*>
is also a synonym for the ap
function from Control.Monad, so this confirms my use of the word "apply".
Brent Yorgey's Typeclassopedia is where I learned most of this. It's an outstanding resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With