- Scheme 91.6%
- Shell 4.5%
- Makefile 2.4%
- M4 1.5%
The 'guix-lib prefix has been added both to disambiguate between (guix
records) mainline and this version and because it may be adopted by
other similar efforts for Guix internal libraries extracted as standalone.
Import (guix records) from
|
||
|---|---|---|
| .guix/modules | ||
| build-aux | ||
| guix-lib/guix | ||
| scripts | ||
| tests/guix | ||
| .gitignore | ||
| .guix-channel | ||
| AUTHORS | ||
| ChangeLog | ||
| configure.ac | ||
| COPYING | ||
| guix.scm | ||
| Makefile.am | ||
| NEWS | ||
| README | ||
| README.md | ||
Guix' declarative record system, as a standalone Guile library
guix-lib-guix-records packages the (guix-lib guix records) module, Guix's declarative record system defined at guix/records.scm, as a standalone Guile library. It lets Guile projects use declarative, functional records without depending on the full Guix.
What it provides
The (guix-lib guix records) module exports:
define-record-type*: an extension of SRFI-9's record definition form with named field initializers, default values, thunked/delayed/innate/sanitized fields, and a functional(inherit …)copy form.this-record: refers to the surrounding record from within a thunked field expression.alist->record: build a record from an association list.object->fields: print a record's fields to a port.recutils->alist: parse a recutils-style stanza into an association list.match-record,match-record-lambda: destructure records by field name.
(use-modules (guix-lib guix records))
(define-record-type* <person> person make-person
person?
(name person-name (default "sara"))
(speak-to person-speak-to (default (current-output-port)) (thunked)))
(define a-person
(person (name "rufy"))) ;=> #<<person> name: "foo" ...>
(define another-person
(person (inherit a-person)
(name "nami")) ;functional update
A note on support
This library is merely a periodic export of (guix records). All development happens in Guix mainline, this is just an experiment to allow using parts of Guix in Guile programs other than Guix. The API is bound to Guix' needs and will change any time it changes in Guix mainline. In case you find bugs specific to how the module renaming affects the library report them here.
Building from source
Guix
guix build -f guix.scm
Autotools
To use autotools you need the following dependencies:
- autoconf
- automake
- guile
- make
- pkg-config
then you can run:
autoreconf -vif
./configure
make
Running the test suite
make check
Guix channel
The repository is also a Guix channel. To add it to your ~/.config/guix/channels.scm:
(cons* (channel
(name 'guix-records)
(url "https://codeberg.org/fishinthecalculator/guix-records.git")
(branch "main"))
%default-channels)
After guix pull the package guix-lib-guix-records.git will be available.
Licence
Files in this repository are distributed under the terms of the GNU GPL version 3 or later, matching Guix mainline.