Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the lense Reference Manual, version 0.0.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 13:58:55 2020 GMT+0.
• Introduction | What lense is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Racket style lenses for the Common Lisp. Portable, extendable, simple.
Lenses objects acting as a first-class accessors build around SETFable places. They are composable by default, which greatly simplifies building nested representations.
This package exports just a few symbols. You can use READ, WRITE (or ACCESS if you prefer to do so) as well as TRANSFORM to interact with lenses. To create a new lense use FOR macro and COMPOSE function.
(defparameter *data* (list 1 2 3))
(defparameter *lense* (lense:for (elt :_ 0)))
(print (lense:read *lense* *data*)) ; => 1
(lense:write *lense* 10 *data*)
(print (lense:read *lense* *data*)) ; => 10
(defparameter *nested-data* (list *data*))
(defparameter *nested-lense* (lense:compose *lense* *lense*))
(print (lense:read *nested-lense* *nested-data*)) ; => 10
(lense:write *nested-lense* 1 *nested-data*)
(print (lense:read *nested-lense* *nested-data*)) ; => 1
(lense:transform *nested-lense* #'1+ *nested-data*)
(print (lense:read *nested-lense* *nested-data*)) ; => 2
(setf (lense:access *nested-lense* *nested-data*) 1)
(print (lense:access *nested-lense* *nested-data*)) ; => 1
Code generated by FOR macro will evaluate arguments for the place only once, regardless of any further calls to READ and WRITE. It will not perform full code walk in search of :_, it MUST occur on the first level. This will probabbly not change because any more complicated behavior would destroy equality between SETFable place and lense.
READ, WRITE, TRANSFORM are all generic functions. In addition to those, programmer may want to specialize GATHER function. ACCESS is just ordinary function that forwards all calls to READ nad WRITE generics and can be ignored.
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The lense system |
Marek Kochanowicz
Marek Kochanowicz
BSD-2
Racket style lenses for the Common Lisp.
0.0.0
lense.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The lense/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
/home/quickref/quicklisp/dists/quicklisp/software/lense-20201220-git/lense.asd
lense (system)
Next: The lense/macros․lisp file, Previous: The lense․asd file, Up: Lisp files [Contents][Index]
Next: The lense/types․lisp file, Previous: The lense/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
lense (system)
macros.lisp
for (macro)
Next: The lense/protocol․lisp file, Previous: The lense/macros․lisp file, Up: Lisp files [Contents][Index]
macros.lisp (file)
lense (system)
types.lisp
Next: The lense/implementation․lisp file, Previous: The lense/types․lisp file, Up: Lisp files [Contents][Index]
types.lisp (file)
lense (system)
protocol.lisp
Next: The lense/documentation․lisp file, Previous: The lense/protocol․lisp file, Up: Lisp files [Contents][Index]
protocol.lisp (file)
lense (system)
implementation.lisp
Previous: The lense/implementation․lisp file, Up: Lisp files [Contents][Index]
implementation.lisp (file)
lense (system)
documentation.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The lense package |
package.lisp (file)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported classes |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Description:
Macro. Expands to construction of BASIC-LENS for designated SETFable place.
Exceptional situations:
Use of this macro should include one symbol :_ in the arguments designating position in the lambda list where OBJECT should be placed. If there is either more than one such symbol in the ARGUMETS or there is none, the CL:PROGRAM-ERROR will be raised.
macros.lisp (file)
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
Description:
SETFable alternative to the READ function.
See also:
–READ
–WRITE
protocol.lisp (file)
(setf access) (function)
protocol.lisp (file)
access (function)
Description:
Stacks lenses on each other to build a COMPOSED-LENS.
Returns:
Instance of COMPOSED-LENSE.
Exceptional situations:
Every argument must be a lense supporting GATHER function.
protocol.lisp (file)
Next: Exported classes, Previous: Exported functions, Up: Exported definitions [Contents][Index]
Description:
This function gathers all elementary lenses from the input lense into the DESTINATION-VECTOR. This is required for the simplicity and efficiency of the COMPOSE function. Constructed COMPOSED-LENSE has flat internal lenses structure which eleminates pointless recursive calls that can potentially occur otherwise.
Returns:
DESTINATION-VECTOR
Exceptional situations:
Will signal CL:TYPE-ERROR (with interactive restart) if DESTINATION-VECTOR is not (AND (VECTOR T) (SATISFIES ADJUSTABLE-ARRAY-P))
protocol.lisp (file)
implementation.lisp (file)
implementation.lisp (file)
Arguments:
–LENSE, LENS used to read the OBJECT.
–OBJECT, OBJECT that is being read.
Description:
Read trough the lens. Use the LENS to retrieve value from the OBJECT.
Returns:
Value obtained.
See also:
–ACCESS
–WRITE
Notes:
Instead of calling this function, one may funcall LENSE object directly on data.
protocol.lisp (file)
implementation.lisp (file)
implementation.lisp (file)
Description:
READ value from the lens. FUNCALL passed transformation on the value. WRITE value back, using the same lense.
Exceptional situations:
–Will signal CL:TYPE-ERROR (with restart) if TRANSFORMATION is not a function.
Notes:
Specialization of this generic function for the COMPOSED-LENSE will not pipe object via the sublenses twice.
protocol.lisp (file)
implementation.lisp (file)
Arguments:
–LENSE, LENS used to read the OBJECT.
–VALUE, VALUE deposited into the OBJECT.
–OBJECT, OBJECT that is being read.
Description:
Write trough the lens. Use the LENS to deposit value into the OBJECT.
See also:
–ACCESS
–READ
protocol.lisp (file)
implementation.lisp (file)
implementation.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
Description:
Elementary lense, acts as a wrapper around an setfable place. Constructed by expansion of LENS:FOR macro.
types.lisp (file)
fundamental-lense (class)
:read-callback
read-callback (generic function)
:write-callback
write-callback (generic function)
Description:
COMPOSED-LENSE pipes all READ, WRITE and COMPOSE calls trough the lenses used to construct the result (from left to right, in the opposite order to the ALEXANDRIA:COMPOSE).
types.lisp (file)
fundamental-lense (class)
:internal-lenses
internal-lenses (generic function)
Description:
Fundamental class of all lenses. All subclasses of this class should support following generic functions: READ, WRITE. TRANSFORM and GATHER have potentially usefull default methods (TRANSFORM simply calls READ and WRITE in a succession which may or may not be efficient, GATHER simply puts the lense into the result vector).
types.lisp (file)
funcallable-standard-object (class)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal generic functions |
Previous: Internal definitions, Up: Internal definitions [Contents][Index]
automatically generated reader method
types.lisp (file)
automatically generated reader method
types.lisp (file)
automatically generated reader method
types.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L |
---|
Jump to: | F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
A C F G I M R T W |
---|
Jump to: | (
A C F G I M R T W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | %
S |
---|
Jump to: | %
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | B C F L P S |
---|
Jump to: | B C F L P S |
---|