edn
| Kind | ffi-zig |
|---|---|
| Categories | parser data-format |
| Keywords | edn parser serialization data-format clojure |
EDN (Extensible Data Notation) parsing and generation for Kit
Files
| File | Description |
|---|---|
.editorconfig | Editor formatting configuration |
.gitignore | Git ignore rules for build artifacts and dependencies |
.tool-versions | asdf tool versions (Zig, Kit) |
LICENSE | MIT license file |
README.md | This file |
examples/basic.kit | Basic usage example |
kit.toml | Package manifest with metadata and dependencies |
src/edn.kit | EDN parse error type. |
tests/edn.test.kit | Tests for edn |
zig/edn.zig | Zig FFI module for edn |
zig/kit_ffi.zig | Zig FFI module for kit ffi |
Dependencies
No Kit package dependencies.
Installation
kit add gitlab.com/kit-lang/packages/kit-edn.gitUsage
import Kit.EDN as EDN
main = fn =>
# Parse an EDN string into a Kit value
match EDN.parse "{:name \"Kit\" :version 1 :active true}"
| Ok value ->
println "name: ${value.name}"
println "version: ${value.version}"
| Err e -> println "Parse error: ${Error.message e}"
# Stringify Kit values to compact EDN
record = {name: "Kit", version: 1, active: true}
println (EDN.stringify record)
# Output: {:name "Kit" :version 1 :active true}
# Stringify lists
println (EDN.stringify [1, 2, 3])
# Output: [1 2 3]
# Stringify individual values
println (EDN.stringify 42) # 42
println (EDN.stringify "hello") # "hello"
println (EDN.stringify :keyword) # :keyword
println (EDN.stringify true) # true
# Pretty-print with indentation
nested = {name: "Kit", items: [1, 2, 3]}
println (EDN.pretty nested)
# Parse keywords and vectors
match EDN.parse "[:a :b :c]"
| Ok value -> println (EDN.stringify value)
| Err e -> println "Error: ${Error.message e}"
# Parse nil
match EDN.parse "nil"
| Ok value -> println (EDN.stringify value)
| Err e -> println "Error: ${Error.message e}"
mainDevelopment
Running Examples
Run examples with the interpreter:
kit run examples/basic.kitCompile examples to a native binary:
kit build examples/basic.kit && ./basicRunning Tests
Run the test suite:
kit testRun the test suite with coverage:
kit test --coverageRunning kit dev
Run the standard development workflow (format, check, test):
kit devThis will:
- Format and check source files in
src/ - Run tests in
tests/with coverage
Generating Documentation
Generate API documentation from doc comments:
kit docNote: Kit sources with doc comments (##) will generate HTML documents in docs/*.html
Cleaning Build Artifacts
Remove generated files, caches, and build artifacts:
kit task cleanNote: Defined in kit.toml.
Local Installation
To install this package locally for development:
kit installThis installs the package to ~/.kit/packages/@kit/edn/, making it available for import as Kit.EDN in other projects.
License
This package is released under the MIT License - see LICENSE for details.
Exported Functions & Types
EDNParseError
EDN parse error type.
match EDN.parse content
| Ok value -> process value
| Err (EDNParseError { message }) ->
println "Parse error: ${message}"Variants
EDNParseError {message}EDN
Marker type for the EDN format. Used with StringEncode/StringDecode traits to distinguish EDN serialization.
Variants
EDN