Relock: record the >= pin form
4aa96ae3
Archived at Sigil 0.19.0: The maintained implementation now lives in codeberg:sigil/sigil. This repository and all tags remain available for provenance, but no further standalone releases will be published.Functional programming utilities for Sigil, providing function composition, partial application, and threading macros.
Add to your package.sgl dependencies:
(from-git url: "codeberg:sigil/sigil-fp")Utilities for composing and partially applying functions.
(import (sigil fp fn))Create new functions by fixing arguments:
(define add10 (partial + 10))
(add10 5) ; => 15
(add10 1 2 3) ; => 16
(define div-by-2 (partial-right / 2))
(div-by-2 10) ; => 5Right-to-left function composition:
(define process (compose string-upcase string-trim))
(process " hello ") ; => "HELLO"
((compose) 42) ; => 42 (identity)Left-to-right function composition (pipeline style):
(define process (pipe string-trim string-upcase))
(process " hello ") ; => "HELLO"Return a function that always returns the given value:
(map (const 0) '(a b c)) ; => (0 0 0)Swap the first two arguments of a function:
((flip cons) '(1 2) 'a) ; => (a 1 2)
((flip -) 3 10) ; => 7Return the logical complement of a predicate:
(filter (complement zero?) '(0 1 0 2 0 3)) ; => (1 2 3)Apply multiple functions to the same arguments, returning a list of results:
((juxt car cdr) '(1 2 3)) ; => (1 (2 3))
((juxt + - *) 3 4) ; => (7 -1 12)Thread values through sequences of expressions, similar to Clojure's threading macros and SRFI-197.
These macros live in(sigil core)now.chain,->, andsome->are part of core, which is auto-imported into every module, so every program already has them in scope without importing anything.(sigil fp chain)re-exports them from core purely for backward compatibility, so existing(import (sigil fp chain))/(import (sigil fp))code keeps working.
;; No import needed — these come from core:
(-> 5 (+ 3) (* 2))
;; Or, for backward compatibility:
(import (sigil fp chain))Thread a value through expressions. Uses _ as a placeholder for the threaded value. When no _ is present, the value is inserted as the first argument.
;; Thread-first (no placeholder)
(chain 5 (+ 3) (* 2))
; => 16
;; Explicit placeholder
(chain '(1 2 3)
(map (lambda (x) (* x 2)) _)
(apply + _))
; => 12
;; Placeholder in various positions
(chain 10 (- 20 _)) ; => 10
(chain 5 (list 1 2 _ 4)) ; => (1 2 5 4)
;; -> is an alias for chain
(-> 5 (+ 3) (* 2)) ; => 16Like ->, but short-circuits and returns #f if any step produces #f:
;; Short-circuits on #f
(some-> #f (+ 1 _)) ; => #f
;; Continues while truthy
(some-> 5 (+ 1 _) (* 2 _)) ; => 12
;; Useful for nullable pipelines
(some-> user
(dict-ref _ name:)
(string-split " " _)
car)sigil deps install sigil build sigil test
BSD-3-Clause
$ git clone https://codeberg.org/sigil/sigil-fp
v0.9.3 — latest by version, released 6 Jul 2026
All releases — 3 tags in this repository.
One page per file, and every line has a permalink.
Relock: record the >= pin form
4aa96ae3
The last 20 commits keep a page here. Everything older lives in the clone.