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-ofis an ordinary Common Lisp function (called outsidecoalton), and⟨symbol⟩must evaluate to acl:symbol.- It looks up
⟨symbol⟩in Coalton’s global type environment (which includes types defined withdefine-type,define-struct,define-exception,define-resumption, anddefine-type-alias). - If
⟨symbol⟩is found,kind-ofreturns itscoalton-impl/typechecker:kindobject; otherwise it returnscl:nil. - Printed kinds display the base kind
Typeas*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
forallbinder annotations, kinds are written usingType,Values, and->(for example,(:f (Type -> Type))), even thoughkind-ofprintsTypeas*. - To print the kinds of all types in a package, call
(coalton:print-type-db OptionalPackage)at the Common Lisp REPL.