Documentation
¶
Overview ¶
Package teal makes .tl (Teal) source files runnable through gopher-lua by embedding the Teal compiler + Lua 5.2 compatibility shims. Consumers do not import this package directly; hex/lua's Environment lazy-loads it when it encounters a .tl file.
Runtime model ¶
Teal's compiler is itself Lua (tl.lua). We load it into the same gopher-lua state that will execute compiled Teal output. Compilation happens by calling tl.process(filename) + tl.pretty_print_ast(ast, "5.1") from Go through the state, producing plain Lua source that gopher-lua then compiles + executes as normal.
See NOTICE.md for attribution + the patch trail on the vendored Lua files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check runs tl.process on the source but stops before code generation, returning any syntax + type errors found. Useful for CI: fail the build on Teal type errors without executing anything.
Types ¶
type Session ¶
Session wraps an LState with a persistent Teal env, so subsequent compiles see prior declarations. Use this for REPLs and any other interactive loop where each snippet is its own "chunk" but must share a symbol table with previous chunks.
Non-Session Compile/Check calls typecheck each snippet in isolation (correct for scripts, wrong for REPLs).
func NewLaxSession ¶
NewLaxSession is like NewSession but flips Teal's lax typecheck mode on. In lax mode Teal permits implicit globals (foo = 12 without an explicit declaration) and generally relaxes strictness — well-suited to REPL interaction where every line is its own chunk and users don't want to sprinkle 'global' declarations.
func NewSession ¶
NewSession initialises a Teal env stashed on L under a private global (_hex_teal_env) with strict typechecking. L must have had Load called on it.
Use NewLaxSession for REPL-friendly loose typechecking that permits implicit globals and Lua-esque patterns.
func (*Session) AddTypeStub ¶
AddTypeStub writes a Teal .d.tl file for moduleName into the session's private types directory (created on first call) and prepends the directory to package.path so Teal's require() resolution finds it.
Callers typically pass the source verbatim from *hex/lua.Environment.Types() — hex/lua/repl.Run does this automatically for Teal sessions.