PtcRunner.Lisp.Eval.Helpers (PtcRunner v0.14.0)

Copy Markdown View Source

Shared helper functions for Lisp evaluation.

Provides type error formatting and type description utilities.

Summary

Functions

Returns the definition-only-form hint for the first matching name, or nil.

Describes the type of a value for error messages.

Formats closure errors with helpful messages.

Generates a type error tuple for FunctionClauseError in builtins.

Functions

definition_only_hint(names)

@spec definition_only_hint(term()) :: String.t() | nil

Returns the definition-only-form hint for the first matching name, or nil.

Accepts one name or a list of them, and answers nil for anything else so callers projecting untrusted diagnostic detail need no shape check first.

describe_type(callable)

@spec describe_type(term()) :: String.t()

Describes the type of a value for error messages.

format_closure_error(reason)

@spec format_closure_error(term()) :: String.t()

Formats closure errors with helpful messages.

type_error_for_args(fun, args)

@spec type_error_for_args(function(), [term()]) :: {:type_error, String.t(), term()}

Generates a type error tuple for FunctionClauseError in builtins.