5 ms·
For the Haskellers in the room, the “K” combinator is “const”, and the “S” combinator is “ap” in the Reader monad. Combinators encode common patterns; for examp
by evincarofautumn 14y ago
For the Haskellers in the room, the “K” combinator is “const”, and the “S” combinator is “ap” in the Reader monad. Combinators encode common patterns; for example, you can use the fact that Sxyz = xz(yz) to write functions that split some input in two, do a computation on both parts, then join the results:
capitalize = (:) . toUpper . head <*> map toLower . tail
Of course, combinators rapidly become unwieldy for anything nontrivial, since they are the essence of point-free style. And most SK calculus terms aren’t typeable in Haskell anyway.