coalton-codegen-ast compiles top-level Coalton forms, prints the typechecked AST for each top-level define to *standard-output*, and returns nil.

Syntax

(coalton-codegen-ast
  ⟨toplevel-form⟩*)

Semantics

  • coalton-codegen-ast accepts the same top-level forms as coalton-toplevel.
  • During compilation, it invokes *codegen-hook* with :AST right after typechecking and before dictionary translation and optimization.
  • For each top-level define binding in the unit, it prints ⟨name⟩ :: ⟨type-scheme⟩ followed by the readable structure of its typechecked body (coalton-impl/typechecker/expression:node-body) to *standard-output*.
  • Unlike coalton-codegen, it prints during evaluation and returns nil.

Examples

(coalton-codegen-ast
  (declare double (Integer -> Integer))
  (define (double x)
    (+ x x)))
;; prints:
;; DOUBLE :: INTEGER → INTEGER
;; #S(NODE-BODY ...)
; => NIL

Other notes