describe-type-of is a Common Lisp REPL helper that prints the type and type aliases of a global Coalton symbol.
Syntax
(describe-type-of ⟨symbol⟩)
Semantics
describe-type-ofis an ordinary Common Lisp function (called outsidecoalton), and⟨symbol⟩must evaluate to acl:symbol.- It inspects
⟨symbol⟩in the current Common Lisp environment and Coalton’s global value environment and prints one line to*standard-output*:- If
⟨symbol⟩has a Common Lispmacro-function(includingdefine-expression-macroanddefine-toplevel-macro), it printsmacro. - If
⟨symbol⟩names a known Coalton value, function, typeclass method, or data constructor, it prints its type scheme with:types-and-aliasesprinting mode enabled. - Otherwise, it prints
unknown.
- If
- Returns zero values
(cl:values).
Examples
(coalton-toplevel
(define-type-alias (Pair :a) (Tuple :a :a))
(declare make-diagonal (:a -> (Pair :a)))
(define (make-diagonal x)
(Tuple x x)))
(describe-type-of 'make-diagonal)
;; prints: ∀ :A. :A → [PAIR :A := TUPLE :A :A]
(describe-type-of 'pipe)
;; prints: macro
Other notes
- Unlike
type-of, which is a Coalton expression form that can inspect arbitrary compound expressions,describe-type-ofis a Common Lisp function that looks up a single symbol in the global environment and always enables:types-and-aliasesdisplay. - To inspect a type alias symbol itself, use
describe-type-alias. To list all values in a package, use(coalton:print-value-db OptionalPackage).