Created
November 25, 2025 20:33
-
-
Save xenodium/83c0f404f811da18b520c1056c82985e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ██████╗ ██╗ █████╗ ██╗ ██╗ ██████╗ ███████╗ | |
| ██╔════╝ ██║ ██╔══██╗ ██║ ██║ ██╔══██╗ ██╔════╝ | |
| ██║ ██║ ███████║ ██║ ██║ ██║ ██║ █████╗ | |
| ██║ ██║ ██╔══██║ ██║ ██║ ██║ ██║ ██╔══╝ | |
| ╚██████╗ ███████╗ ██║ ██║ ╚██████╔╝ ██████╔╝ ███████╗ | |
| ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ | |
| ██████╗ ██████╗ ██████╗ ███████╗ | |
| ██╔════╝ ██╔═══██╗ ██╔══██╗ ██╔════╝ | |
| ██║ ██║ ██║ ██║ ██║ █████╗ | |
| ██║ ██║ ██║ ██║ ██║ ██╔══╝ | |
| ╚██████╗ ╚██████╔╝ ██████╔╝ ███████╗ | |
| ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ | |
| Welcome to agent shell | |
| Type help and press RET for details. | |
| Like this package? Consider ✨sponsoring✨ | |
| <shell-maker-failed-command> | |
| Claude Code> can you tell me what l-function.el is about? | |
| <shell-maker-end-of-prompt> | |
| ▼ completed Starting agent | |
| Creating client... | |
| Subscribing... | |
| Initializing... | |
| Creating session... | |
| Ready | |
| ▼ Agent capabilities | |
| prompt image and embedded context | |
| mcp http and sse | |
| ▼ Available modes | |
| Always Ask Prompts for permission on first use of each tool | |
| Accept Edits Automatically accepts file edit permissions for the session | |
| Plan Mode Claude can analyze but not modify files or execute commands | |
| Bypass Permissions Skips all permission prompts | |
| ▼ Available commands | |
| /compact Clear conversation history but keep a summary in context. Optional: /compact [instructions for summarization] | |
| /init Initialize a new CLAUDE.md file with codebase documentation | |
| /pr-comments Get comments from a GitHub pull request | |
| /review Review a pull request | |
| /security-review Complete a security review of the pending changes on the current branch | |
| I'll read the file to understand what it's about. | |
| ▼ completed read Read l-function.el | |
| ``` | |
| Reading file failed: Cannot read properties of undefined (reading 'indexOf') | |
| ``` | |
| Let me try to find the file first: | |
| ▼ completed search Find `**/*l-function.el` | |
| /Users/alvaro/stuff/active/code/third_party/l-el/lib/utilities/l-function.el | |
| ▼ completed read Read lib/utilities/l-function.el | |
| ``` | |
| ;;; package --- Summary ;;; -*- lexical-binding: t; l-syntax: t; -*- | |
| ;; Copyright (C) 2025 Laura Viglioni | |
| ;; Author: Laura Viglioni | |
| ;; Keywords: lisp, functional, programming, utilities | |
| ;; URL: https://github.com/viglioni/l-el | |
| ;; This file is not part of GNU Emacs. | |
| ;; This program is free software: you can redistribute it and/or modify | |
| ;; it under the terms of the GNU General Public License as published by | |
| ;; the Free Software Foundation, either version 3 of the License, or | |
| ;; (at your option) any later version. | |
| ;; This program is distributed in the hope that it will be useful, | |
| ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| ;; GNU General Public License for more details. | |
| ;; You should have received a copy of the GNU General Public License | |
| ;; along with this program. If not, see <https://www.gnu.org/licenses/>. | |
| ;;; Commentary: | |
| ;; This is a sublibrary of l.el providing additional functionality. | |
| ;; This file uses l-syntax | |
| ;; | |
| ;; since 0.4.0 | |
| ;;; Code: | |
| (require 'l-main) | |
| (defmacro lcomp (&rest fns) | |
| "`lcomp' provides function composition right to left. | |
| Function composition allows you to combine multiple functions into a single | |
| function, where the output of one function becomes the input of the next. | |
| The composition is applied right to left, meaning the rightmost function | |
| is applied first. | |
| Each argument is automatically wrapped with `__', so you can use the `__' | |
| placeholder syntax directly: (lcomp (+ __ 1) (* __ 2)) instead of | |
| \(lcomp (__ (+ __ 1)) (__ (* __ 2))). | |
| since: 0.4.0 | |
| Arguments: | |
| - No arguments: returns identity function | |
| - One function: returns the function unchanged | |
| - Two or more functions: returns composed function | |
| Examples: | |
| Basic composition with lambdas: | |
| \(ldef double (l x -> (* 2 x))) | |
| \(ldef add-one (l x -> (+ 1 x))) | |
| \(funcall (lcomp add-one double) 5) ;; => 11 | |
| Using __ placeholder syntax: | |
| \(funcall (lcomp (+ __ 1) (* __ 2)) 5) ;; => 11 | |
| With `with-l' for cleaner syntax: | |
| \(with-l ((lcomp (+ __ 1) (* __ 2)) 5)) ;; => 11 | |
| Multiple function composition: | |
| \(with-l ((lcomp (l x -> (+ x 1)) (* __ 2) (* __ 3)) 10)) ;; => 61 | |
| String processing example: | |
| \(with-l ((lcomp upcase string-trim) \" hello \")) ;; => \"HELLO\" | |
| With local bindings: | |
| \(let ((square (lambda (x) (* x x)))) | |
| (with-l ((lcomp (+ __ 1) square) 3))) ;; => 10" | |
| `(l--comp ,@(mapcar (lambda (x) `(__ ,x)) fns))) | |
| @doc "Internal function for `lcomp'. Composes functions right to left." | |
| (ldef l--comp () (l x -> x)) | |
| (ldef l--comp ((f :function)) f) | |
| (ldef l--comp ((f :function) (g :function)) | |
| `(lambda (&rest args) (funcall (quote ,f) (apply (quote ,g) args)))) | |
| (ldef l--comp ((f :function) (g :function) (fn-list :rest)) | |
| (apply 'l--comp (l--comp f g) fn-list)) | |
| (provide 'l-function) | |
| ;;; l-function.el ends here | |
| ``` | |
| `l-function.el` is a sublibrary of **l.el** that provides **function composition** utilities for Emacs Lisp. Here's what it does: | |
| ## Main Feature: `lcomp` macro | |
| The file provides the `lcomp` macro, which enables right-to-left function composition (similar to mathematical function composition). Key aspects: | |
| - **Right-to-left composition**: The rightmost function is applied first, then the result flows leftward | |
| - **Automatic `__` wrapping**: Each argument is automatically wrapped with `__`, so you can use placeholder syntax directly | |
| - **Multiple arities**: Handles 0, 1, or many functions gracefully | |
| ## Examples from the code: | |
| ```elisp | |
| ;; Simple composition: first multiply by 2, then add 1 | |
| (funcall (lcomp (+ __ 1) (* __ 2)) 5) ;; => 11 | |
| ;; String processing: trim, then uppercase | |
| (with-l ((lcomp upcase string-trim) " hello ")) ;; => "HELLO" | |
| ;; Multiple functions | |
| (with-l ((lcomp (+ __ 1) (* __ 2) (* __ 3)) 10)) ;; => 61 | |
| ``` | |
| The implementation uses pattern matching via `ldef` to handle different cases: | |
| - No functions → identity function | |
| - One function → return it unchanged | |
| - Two or more → compose them using the internal `l--comp` function | |
| This is a functional programming utility that was added in version 0.4.0 of l.el. | |
| Claude Code> can you fix the Intrnal typo? | |
| <shell-maker-end-of-prompt> | |
| I'll fix the typo "Intrnal" to "Internal" in the file. | |
| ▼ failed edit Edit `lib/utilities/l-function.el` | |
| ``` | |
| The provided `old_string` does not appear in the file: "@doc "Internal function for `lcomp'. Composes functions right to left."". | |
| No edits were applied. | |
| ``` | |
| ╭─────────╮ | |
| │ changes │ | |
| ╰─────────╯ | |
| Let me read the file again to see the exact text: | |
| ▼ completed search grep "Intrnal" lib/utilities/l-function.el | |
| 78:@doc "Intrnal function for `lcomp'. Composes functions right to left." | |
| [Showing results with pagination = limit: 20, offset: 0] | |
| ▼ completed edit Edit `lib/utilities/l-function.el` | |
| ╭─────────╮ | |
| │ changes │ | |
| ╰─────────╯ | |
| @@ -75,7 +75,7 @@ | |
| `(l--comp ,@(mapcar (lambda (x) `(__ ,x)) fns))) | |
| -@doc "Intrnal function for `lcomp'. Composes functions right to left." | |
| +@doc "Internal function for `lcomp'. Composes functions right to left." | |
| (ldef l--comp () (l x -> x)) | |
| (ldef l--comp ((f :function)) f) | |
| (ldef l--comp ((f :function) (g :function)) | |
| Fixed! I've corrected the typo "Intrnal" to "Internal" in the documentation comment at lib/utilities/l-function.el:78. | |
| Claude Code> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment