Name | # | Haskell | Ramda | Sanctuary | Signature |
---|---|---|---|---|---|
identity | I | id |
identity |
I |
a β a |
constant | K | const |
always |
K |
a β b β a |
apply | A | ($) |
call |
I ΒΉ |
(a β b) β a β b |
thrush | T | (&) |
applyTo |
T |
a β (a β b) β b |
duplication | W | join Β² |
unnest Β² |
join Β² |
(a β a β b) β a β b |
flip | C | flip |
flip |
flip |
(a β b β c) β b β a β c |
compose | B | (.) , fmap Β² |
map Β² |
compose , map Β² |
(b β c) β (a β b) β a β c |
substitution | S | (<*>) Β² |
ap Β² |
ap Β² |
(a β b β c) β (a β b) β a β c |
chain | S_Β³ | (=<<) Β² |
chain Β² |
chain Β² |
(a β b β c) β (b β a) β b β c |
converge | S2Β³ | apply2way , liftA2 Β², liftM2 Β² |
lift2 Β² |
(b β c β d) β (a β b) β (a β c) β a β d |
|
psi | P | on |
on |
on |
(b β b β c) β (a β b) β a β a β c |
fix-pointβ΄ | Y | fix |
(a β a) β a |
ΒΉ) The A-combinator can be implemented as an alias of the I-combinator. Its implementation in Haskell exists because the infix nature gives it some utility. Its implementation in Ramda exists because it is overloaded with additional functionality.
Β²) Algebras like ap
have different implementations for different types.
They work like Function combinators only for Function inputs.
Β³) I could not find a consistent name for these combinators, but they are common enough in the JavaScript ecosystem to justify their inclusion. I named them myself in order to refer to their implementation.
β΄) In JavaScript and other non-lazy languages, it is impossible to
implement the Y-combinator. Instead a variant known as the applicative or
strict fix-point combinator is implemented. This variant is sometimes
rererred to as the Z-combinator. The implementation found in combinators.js
is the strictly evaluated "Z" combinator, which needs the extra wrapper
around g (g)
on the right hand side.
@JamieDixon: I came here wondering if the combinator I was about to write had a well-known name.
I guess not. But now I think
FooComb
may be stuck in my head!