Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the trivialib.type-unify Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Apr 19 18:08:44 2021 GMT+0.
• Introduction | What trivialib.type-unify is all about | |
• Systems | The systems documentation | |
• Modules | The modules documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
typexpand
in introspect-environment.;;; ------------- type-unify1 --------------
;;; single query variant
(type-unify1 '(a) ; type variable
'(array a *) ; template
'(array char (3))) ; actual type specifier
;; '((A . CHAR)), T ; unification
;;; It is able to infer that the STRING type is actually an abbreviation of (ARRAY CHARACTER *).
;;; note that our code does not depend on an implimentation-dependent TYPEXPAND in this regard.
;;; (== we do not require TYPEXPAND will expand STRING into (ARRAY CHARACTER *).
;;; For the detailed mechanism, see the source code of TYPE-R.)
(type-unify1 '(a b)
'(array a b)
'string)
;; ((A . CHARACTER) (B . *)), T
;;; Nested types
(type-unify1 '(a b)
'(cons (cons a b) (cons b a))
'(cons (cons fixnum string) (cons string fixnum)))
;; ((A . FIXNUM) (B . STRING)), T
;;; deftyped types are expanded by typexpand --- implementation dependent.
;;; Works on major implementation: ccl, sbcl.
;;; Using introspect-environment as a compatibility layer.
(deftype cons2 (x) `(cons ,x ,x))
;; CONS2
(type-unify1 '(a b)
'(cons2 (cons2 a))
'(cons (cons fixnum fixnum) (cons fixnum fixnum)))
;; ((A . FIXNUM)), T
(type-unify1 '(a b)
'(cons (cons a a) (cons a a))
'(cons2 (cons2 fixnum)))
;; ((A . FIXNUM)), T
;;; number-related types
(type-unify1 '(a) '(integer * a) 'fixnum)
;; ((A . 4611686018427387903)), T
(type-unify1 '(a) '(integer * a) '(unsigned-byte 5))
;; ((A . 31)), T
(type-unify1 '() `(integer ,most-negative-fixnum ,most-positive-fixnum) 'FIXNUM)
;; NIL, T
;;; ------------- type-unify --------------
;;; multi-query variant
(type-unify '(a)
'(a a)
'((array * 6) (array char *)))
;; --> '((a . (and (array * 6) (array char *)))), t
;;; We do not try to merge the resulting assignment of unification.
;;; However, we DO detect the disjointness of types.
(type-unify '(a) '(a a) '((array * 6) (array * 7))) ; -> nil, nil
(type-unify '(a) '(a a) '((array * 6) (array * (* *)))) ; -> nil, nil
(type-unify '(a) '(a a) '((array * (* * *)) (array * (* *)))) ; -> nil, nil
(type-unify '(a) '(a a) '((array * (* *)) (array * (* * *)))) ; -> nil, nil
(type-unify '(a) '(a a) '((array base-char) (array extended-char))) ; -> nil, nil
(type-unify '(a) '(a a) '(complex real)) ; -> nil, nil
(type-unify '(a) '(a a) '(rational float)) ; -> nil, nil
(type-unify '(a) '(a a) '(integer ratio)) ; -> nil, nil
;; When no assignment is required, it means a success, and the secondary value is T.
(type-unify '(a) '() '()) ;; -> nil, t (a is unassigned)
(type-unify '() '() '()) ;; -> nil, t (a is unassigned)
(type-unify '() '(fixnum) '(fixnum)) ;; -> nil, t (a is unassigned)
(type-unify '() '(number) '(fixnum)) ;; -> nil, t (a is unassigned)
This library is at least tested on implementation listed below:
Also, it depends on the following libraries:
Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com)
Licensed under the LLGPL License.
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The trivialib.type-unify system |
Masataro Asai
LLGPL
unifies a polimorphic type specifier with type variables against actual type specifiers
0.1
trivialib.type-unify.asd (file)
src (module)
Modules are listed depth-first from the system components tree.
• The trivialib.type-unify/src module |
trivialib.type-unify (system)
src/
package.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The trivialib.type-unify.asd file | ||
• The trivialib.type-unify/src/package.lisp file |
Next: The trivialib․type-unify/src/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
trivialib.type-unify.asd
trivialib.type-unify (system)
Previous: The trivialib․type-unify․asd file, Up: Lisp files [Contents][Index]
src (module)
src/package.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The trivialib.type-unify 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 functions |
Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Unify the type templates against types.
TYPES is a list of type specifiers.
TYPEVARS is a list of symbols.
TEMPLATES is a list of type specifiers, but may also contain
the elements of TYPEVARS somewhere in the tree.
TYPE-UNIFY assumes that the unification is the conjunction of each pair of a template and a type.
If some pair fails to unify, then the whole pairs fail to unify.
Also, if some unification (assignment to type variable) in a given pair
contradicts the other assignment, then the whole pairs fail to unify.
Returns (values result unify-p), where the result is an alist containing the assignment of unification and unify-p is a boolean indicating if the given template unifies against the given types.
package.lisp (file)
Unify the type template against a type.
TYPE is a type specifiers.
TYPEVARS is a list of symbols.
TEMPLATE is a type specifiers, but may contain the elements of TYPEVARS somewhere in the tree.
Returns (values result unify-p), where the result is an alist containing the assignment of unification and unify-p is a boolean indicating if the given template unifies against the given types.
package.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal functions |
Previous: Internal definitions, Up: Internal definitions [Contents][Index]
package.lisp (file)
package.lisp (file)
package.lisp (file)
package.lisp (file)
package.lisp (file)
package.lisp (file)
package.lisp (file)
package.lisp (file)
package.lisp (file)
package.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 M T |
---|
Jump to: | F L M T |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | %
F M R S T U |
---|
Jump to: | %
F M R S T U |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | P S T |
---|
Jump to: | P S T |
---|