The trivialib.type-unify Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The trivialib.type-unify Reference Manual

This is the trivialib.type-unify Reference Manual, version 0.1, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 12:43:08 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Trivialib.Type-Unify

Build Status

Usage

;;; ------------- 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)

Dependencies

This library is at least tested on implementation listed below:

Also, it depends on the following libraries:

Installation

Author

Copyright

Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com)

License

Licensed under the LLGPL License.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 trivialib.type-unify

Author

Masataro Asai

Contact

guicho2.71828@gmail.com

License

LLGPL

Description

unifies a polimorphic type specifier with type variables against actual type specifiers

Version

0.1

Dependencies
Source

trivialib.type-unify.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 trivialib.type-unify/src

Parent

trivialib.type-unify (system)

Location

src/

Component

package.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 trivialib.type-unify.asd

Location

trivialib.type-unify.asd

Systems

trivialib.type-unify (system)

Packages

trivialib.type-unify-asd


Previous: , Up: Lisp files   [Contents][Index]

4.1.2 trivialib.type-unify/src/package.lisp

Parent

src (module)

Location

src/package.lisp

Packages

trivialib.type-unify

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 trivialib.type-unify-asd

Source

trivialib.type-unify.asd

Use List

Previous: , Up: Packages   [Contents][Index]

5.2 trivialib.type-unify

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Functions

Function: type-unify TYPEVARS TEMPLATES TYPES

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

trivialib.type-unify

Source

package.lisp (file)

Function: type-unify1 TYPEVARS TEMPLATE TYPE

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

trivialib.type-unify

Source

package.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Functions

Function: %unify-numeroid TYPEVARS TEMPLATE TYPE
Package

trivialib.type-unify

Source

package.lisp (file)

Function: merge-dimensions &optional A B
Package

trivialib.type-unify

Source

package.lisp (file)

Function: merge-mappings-as-and MAPPING1 MAPPING2
Package

trivialib.type-unify

Source

package.lisp (file)

Function: merge-mappings-as-or MAPPING1 MAPPING2
Package

trivialib.type-unify

Source

package.lisp (file)

Function: remove-larger SEQUENCE PARTIAL-ORDER<
Package

trivialib.type-unify

Source

package.lisp (file)

Function: remove-smaller SEQUENCE PARTIAL-ORDER<
Package

trivialib.type-unify

Source

package.lisp (file)

Function: strict-subtypep-or-indifferent A B
Package

trivialib.type-unify

Source

package.lisp (file)

Function: unify-arrayoid TYPEVARS TEMPLATE TYPE
Package

trivialib.type-unify

Source

package.lisp (file)

Function: unify-dimensions TYPEVARS DIMENSIONS1 DIMENSIONS2
Package

trivialib.type-unify

Source

package.lisp (file)

Function: unify-numeroid TYPEVARS TEMPLATE TYPE
Package

trivialib.type-unify

Source

package.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   M   T  
Index Entry  Section

F
File, Lisp, trivialib.type-unify.asd: The trivialib<dot>type-unify<dot>asd file
File, Lisp, trivialib.type-unify/src/package.lisp: The trivialib<dot>type-unify/src/package<dot>lisp file

L
Lisp File, trivialib.type-unify.asd: The trivialib<dot>type-unify<dot>asd file
Lisp File, trivialib.type-unify/src/package.lisp: The trivialib<dot>type-unify/src/package<dot>lisp file

M
Module, trivialib.type-unify/src: The trivialib<dot>type-unify/src module

T
trivialib.type-unify.asd: The trivialib<dot>type-unify<dot>asd file
trivialib.type-unify/src: The trivialib<dot>type-unify/src module
trivialib.type-unify/src/package.lisp: The trivialib<dot>type-unify/src/package<dot>lisp file

Jump to:   F   L   M   T  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %  
F   M   R   S   T   U  
Index Entry  Section

%
%unify-numeroid: Internal functions

F
Function, %unify-numeroid: Internal functions
Function, merge-dimensions: Internal functions
Function, merge-mappings-as-and: Internal functions
Function, merge-mappings-as-or: Internal functions
Function, remove-larger: Internal functions
Function, remove-smaller: Internal functions
Function, strict-subtypep-or-indifferent: Internal functions
Function, type-unify: Exported functions
Function, type-unify1: Exported functions
Function, unify-arrayoid: Internal functions
Function, unify-dimensions: Internal functions
Function, unify-numeroid: Internal functions

M
merge-dimensions: Internal functions
merge-mappings-as-and: Internal functions
merge-mappings-as-or: Internal functions

R
remove-larger: Internal functions
remove-smaller: Internal functions

S
strict-subtypep-or-indifferent: Internal functions

T
type-unify: Exported functions
type-unify1: Exported functions

U
unify-arrayoid: Internal functions
unify-dimensions: Internal functions
unify-numeroid: Internal functions

Jump to:   %  
F   M   R   S   T   U  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   P   S   T  
Index Entry  Section

P
Package, trivialib.type-unify: The trivialib<dot>type-unify package
Package, trivialib.type-unify-asd: The trivialib<dot>type-unify-asd package

S
System, trivialib.type-unify: The trivialib<dot>type-unify system

T
trivialib.type-unify: The trivialib<dot>type-unify system
trivialib.type-unify: The trivialib<dot>type-unify package
trivialib.type-unify-asd: The trivialib<dot>type-unify-asd package

Jump to:   P   S   T