Check the latest release code.
l.el provides a comprehensive modern functional programming approach to writing Emacs Lisp, drawing inspiration from Common Lisp, Haskell, and Elixir. This library transforms Emacs Lisp into a more expressive functional programming language with advanced features including automatic currying, sophisticated pattern matching, type systems, syntax transformations, and specialized development tools.
| Emacs Version | Linux | macOS Intel | macOS ARM64 |
|---|---|---|---|
| 26.3 | ✅ | ✅ | N/A |
| 27.2 | ✅ | ✅ | N/A |
| 28.2 | ✅ | ✅ | ✅ |
| 29.4 | ✅ | ✅ | ✅ |
| 30.1 | ✅ | ✅ | ✅ |
All versions are tested on every push via GitHub Actions CI.
This lib is currently written on macOS M4 Max with Emacs 29.4, only QAed in this setup.
;; -*- l-syntax: t; -*-
@doc "A function that returns the nth Fibonacci number.
This function grows exponentially and demonstrates direct value matching."
(ldef fib 0 -> 0)
(ldef fib 1 -> 1)
(ldef fib (n :integer) ->
(+ (fib (- n 1))
(fib (- n 2))))
@doc "This function calculates delta in a quadratic function
and demonstrates automatic currying capabilities."
(ldef delta (a :number) (b :number) (c :number) ->
(- (* b b) (* 4 a c)))
;; Multiple calling styles with automatic currying:
((((delta) 1) 2) 3) ;; Chained partial application
(delta 1 2 3) ;; Direct application
(funcall (delta 1 2) 3) ;; Partial with funcall
@doc "Sum function with rest parameters for variadic arguments."
(ldef sum (nums :rest) -> (apply '+ nums))
(sum 1 2 3 4 5) ;; => 15
@doc "Greeting function with direct value matching."
(ldef greet "Alice" -> "Hello, Alice!")
(ldef greet (name :string) -> (concat "Hi, " name "!"))
(greet "Alice") ;; => "Hello, Alice!"
(greet "Bob") ;; => "Hi, Bob!"- **Direct value matching** - Match literal values directly: numbers, strings, keywords, quoted symbols, nil, t, vectors, and lists
- **Type-based dispatch** - Comprehensive type system with primitive types, category types, and parameterized types (
:instance_of,:list_of) - **Automatic currying** - Functions curry automatically when called with fewer arguments than defined
- **Lexicographic specificity** - Intelligent pattern ordering ensures most specific patterns match first
- **Arrow syntax** - Clean, modern syntax with
->for lambdas (l) and function definitions (ldef) - **Partial application** -
lpartialfor creating partially applied functions - **Placeholder substitution** - Elegant
__placeholder for concise anonymous functions - **Function composition** -
lcompandlpipefor composing transformations
- **Enhanced major mode** -
l-modewith specialized syntax highlighting for ldef functions, calls, and arrows - **Elixir-style documentation** -
@docmacro for beautiful, discoverable function documentation - **Syntax transformation** -
with-landl-syntaxenable natural curried function call syntax without explicit funcall - **Type predicates** - Extensive type checking with 30+ built-in predicates plus parameterized types
- **Rest parameters** - Variadic functions with
(param :rest)syntax - **Generic function management** - Tools for inspecting and cleaning up ldef functions
- **Custom exceptions** - Structured error handling with
l-raise - **Specialized loading** -
l-requirewith automatic l-syntax processing
Check changelog and breaking changes for version history.
This package is not on MELPA/ELPA (yet?), but you can install via use-package/straight:
(use-package l
;; clones latest release
:straight (l :type git :host github :repo "viglioni/l-el" :branch "latest-release")
:mode ("\\.el\\'" . l-mode) ;; Enhanced syntax highlighting
:custom
(l-syntax t) ;; Optional: globally enable l-syntax transformations
:config
(l-syntax-advices) ;; Enable automatic syntax transformation
;; ...
)Or clone this repository, add l.el to your load path and require it:
(require 'l)The l-syntax variable controls syntax transformation behavior and can be configured in multiple ways:
***Global Configuration:***
(setq l-syntax t)
(l-syntax-advices) ; Enable automatic transformation for evaluation functions***File-local Configuration (Property Line):***
;; -*- l-syntax: t; -*-***File-local Configuration (Local Variables):***
;; Local Variables:
;; l-syntax: t
;; End:When enabled, l-syntax automatically wraps expressions in with-l during eval-last-sexp, eval-region, eval-buffer, load-file, and load operations, enabling natural curried function syntax without explicit with-l wrapping.
See API Reference for the complete documentation of all functions, macros, and variables.
For breaking changes between versions, see Breaking Changes.
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.
For information on contributing, running tests, and the release process, see Development Guide.