kind-of is a Common Lisp function that returns the kind of a Coalton type, struct, or type alias.

Syntax

(kind-of ⟨symbol⟩)

Semantics

  • kind-of is an ordinary Common Lisp function (called outside coalton), and ⟨symbol⟩ must evaluate to a cl:symbol.
  • It looks up ⟨symbol⟩ in Coalton’s global type environment (which includes types defined with define-type, define-struct, define-exception, define-resumption, and define-type-alias).
  • If ⟨symbol⟩ is found, kind-of returns its coalton-impl/typechecker:kind object; otherwise it returns cl:nil.
  • Printed kinds display the base kind Type as * and higher-order kinds with -> (or → when Unicode printing is enabled), associating to the right.

Examples

(kind-of 'Integer)
; => *

(kind-of 'List)
; => * → *

(kind-of 'Result)
; => * → (* → *)

(kind-of 'UnknownType)
; => COMMON-LISP:NIL

Other notes

  • In forall binder annotations, kinds are written using Type, Values, and -> (for example, (:f (Type -> Type))), even though kind-of prints Type as *.
  • To print the kinds of all types in a package, call (coalton:print-type-db OptionalPackage) at the Common Lisp REPL.