<jupyter_start><jupyter_text>IntroductionRecently I read the very interesting [Compiling to Categories](http://conal.net/papers/compiling-to-categories/compiling-to-categories.pdf) paper by <NAME>.He presents the idea to compile haskell programs into a expressions of closed cartesian categories by $\lambda$-elimination.The process applied reminded me of the [bracket abstraction](https://crypto.stanford.edu/~blynn/lambda/sk.html) used when compiling $\lambda$-terms to $SKI$-Combinators.In this notebook I'm studying this connection. bracket abraction in combinatory logic$\lambda$-terms can be converted to variable free combinator terms with a process called bracket abstraction.Bracket abstraction $[]$ is defined by the following equations:\begin{align} [\lambda x.x]   & = I \\[\lambda x.y]   & = Ky \\[\lambda x.P Q] & = S [\lambda x.P] [\lambda x.Q]\end{align}where the combinators $I$, $K$, and $S$ are defined as follows:\begin{align}I x & = x \\K y x & = y \\S p q x & = (p x) (q x)\end{align}In Haskell this combinators could be implemented as follows (we have to use lower case letters as Uppercase first letters are reserved for contructors in Haskell):```haskelli :: a -> ai x = xk :: a -> b -> ak y _ = ys :: (a -> b -> c) -> (a -> b) -> a -> cs p q x = (p x) (q x)  ```Once the $\lambda$-terms are compiled to combinator terms, these terms can be interpreted quite efficiently as they don't contain any variables and so no environment-handling is needed.Combinator terms also allow to apply several more advanced interpretation techniques like graph-reduction, node-sharing, parallel reduction, etc. Closed Cartesian Categories Both $I$ and $K$ are part of the Haskell standard prelude under the names `id` and `const`:```haskell-- | Identity function.id :: a -> aid x =  x-- | @const x@ is a unary function which evaluates to @x@ for all inputs.const :: a -> b -> aconst x _ =  x```<jupyter_code>i :: a -> a
i x = x


i 8<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11922881785895484, 'fraction_numerical': 0.0005073566717402334, 'mean_word_length': 4.135416666666667, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 19, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '190121', 'license': 'Apache-2.0', 'n_tokens_mistral': 594, 'n_tokens_neox': 554, 'n_words': 254, 'path': 'Closed Cartesian Categories and the SKI Combinators.ipynb', 'repo_name': 'thma/lambda-cat', 'size': '1977'}