The narrowed-types Reference Manual

Table of Contents

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

The narrowed-types Reference Manual

This is the narrowed-types Reference Manual, version 0.1, generated automatically by Declt version 2.3 "Robert April" on Tue Jan 09 15:23:59 2018 GMT+0.


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

1 Introduction

narrowed-types

Type definitions narrowed with predicates

Description

This Common Lisp package provides a single macro which helps you define type specifiers for subsets, on the basis on an existing supertype and a condition expressed on the value.

DEFMACRO deftype-narrowed ((var type super-type) &body body)

DEFTYPE-NARROWED defines a type with name TYPE as well as a matching predicate TYPE-p.
The instances of the resulting type are the subset of instances of SUPER-TYPE which satisfy
a condition on VAR expressed by the BODY of the statement.

Example

This simple example defines a type for the odd integers.

(deftype-narrowed (x odd-integer integer)
  (oddp x))

Note: In the body of the example, the argument x to oddp is guaranteed to be an instance of the supertype integer.

The type odd-integer is usable in any context where a type specifier is expected. This includes standard forms such as typep, check-type, typecase, the, defstruct, defclass. You may not use it however to specialize a generic method.

(typecase x
  (odd-integer :odd)
  (integer :even)
  (t :other))

For some more usage examples, see tests.

References

CLHS 4.2.3: Type Specifiers


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 narrowed-types

Author

JP Cimalando

License

BSD

Description

Type definitions narrowed with predicates

Version

0.1

Source

narrowed-types.asd (file)

Component

narrowed-types.lisp (file)


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

3 Files

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


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

3.1 Lisp


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

3.1.1 narrowed-types.asd

Location

narrowed-types.asd

Systems

narrowed-types (system)


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

3.1.2 narrowed-types/narrowed-types.lisp

Parent

narrowed-types (system)

Location

narrowed-types.lisp

Packages

narrowed-types

Exported Definitions

deftype-narrowed (macro)


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

4 Packages

Packages are listed by definition order.


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

4.1 narrowed-types

Source

narrowed-types.lisp (file)

Use List

common-lisp

Exported Definitions

deftype-narrowed (macro)


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

5 Definitions

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


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

5.1 Exported definitions


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

5.1.1 Macros

Macro: deftype-narrowed (VAR TYPE SUPER-TYPE) &body BODY

DEFTYPE-NARROWED defines a type with name TYPE as well as a matching predicate TYPE-p. The instances of the resulting type are the subset of instances of SUPER-TYPE which satisfy a condition on VAR expressed by the BODY of the statement.

Package

narrowed-types

Source

narrowed-types.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   N  
Index Entry  Section

F
File, Lisp, narrowed-types.asd: The narrowed-types<dot>asd file
File, Lisp, narrowed-types/narrowed-types.lisp: The narrowed-types/narrowed-types<dot>lisp file

L
Lisp File, narrowed-types.asd: The narrowed-types<dot>asd file
Lisp File, narrowed-types/narrowed-types.lisp: The narrowed-types/narrowed-types<dot>lisp file

N
narrowed-types.asd: The narrowed-types<dot>asd file
narrowed-types/narrowed-types.lisp: The narrowed-types/narrowed-types<dot>lisp file

Jump to:   F   L   N  

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

A.2 Functions

Jump to:   D   M  
Index Entry  Section

D
deftype-narrowed: Exported macros

M
Macro, deftype-narrowed: Exported macros

Jump to:   D   M  

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

A.3 Variables


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

A.4 Data types

Jump to:   N   P   S  
Index Entry  Section

N
narrowed-types: The narrowed-types system
narrowed-types: The narrowed-types package

P
Package, narrowed-types: The narrowed-types package

S
System, narrowed-types: The narrowed-types system

Jump to:   N   P   S