Overview
Theglyph Go package implements GLYPH, a token-optimized codec designed for LLM interactions. GLYPH provides a dual encoding system (GLYPH-T for text and GLYPH-B for binary) with strong typing, schema validation, and streaming support.
Installation
Import
Key Features
- LLM-friendly syntax: Easy for models to emit and repair
- Token-efficient: Short keys, no quotes, structural compression
- Strongly typed: Schema-driven validation with constraints
- Streamable: Frame-based incremental parsing
- Deterministic: Canonical representation for stable hashing
- Round-trippable: Seamless JSON and SJSON interop
Quick Start
Creating Values
Parsing GLYPH-T Text
Emitting GLYPH-T Text
Working with Values
Data Model
GLYPH supports the following types:Scalars
null- Null value (∅)bool- Boolean (t/f)int- 64-bit integerfloat- 64-bit floatstr- UTF-8 stringbytes- Binary datatime- ISO-8601 timestampid- Reference ID (^prefix:value)
Containers
list- Ordered array of valuesmap- Unordered key-value pairsstruct- Typed struct with named fields
Special
sum- Tagged union (variant type)ref- Reference to another value
GLYPH-T Syntax
Error Handling
The Go API uses both error returns and result types:JSON Interop
Binary Encoding
Next Steps
- Core Types - Detailed GValue API
- Parsing - Parse options and error handling
- Streaming - Incremental parsing and validation