edn

EDN (Extensible Data Notation) parsing and generation for Kit

Files

FileDescription
.editorconfigEditor formatting configuration
.gitignoreGit ignore rules for build artifacts and dependencies
.tool-versionsasdf tool versions (Zig, Kit)
LICENSEMIT license file
README.mdThis file
examples/basic.kitBasic usage example
kit.tomlPackage manifest with metadata and dependencies
src/edn.kitEDN parse error type.
tests/edn.test.kitTests for edn
zig/edn.zigZig FFI module for edn
zig/kit_ffi.zigZig FFI module for kit ffi

Dependencies

No Kit package dependencies.

Installation

kit add gitlab.com/kit-lang/packages/kit-edn.git

Usage

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}"

main

Development

Running Examples

Run examples with the interpreter:

kit run examples/basic.kit

Compile examples to a native binary:

kit build examples/basic.kit && ./basic

Running Tests

Run the test suite:

kit test

Run the test suite with coverage:

kit test --coverage

Running kit dev

Run the standard development workflow (format, check, test):

kit dev

This will:

  1. Format and check source files in src/
  2. Run tests in tests/ with coverage

Generating Documentation

Generate API documentation from doc comments:

kit doc

Note: Kit sources with doc comments (##) will generate HTML documents in docs/*.html

Cleaning Build Artifacts

Remove generated files, caches, and build artifacts:

kit task clean

Note: Defined in kit.toml.

Local Installation

To install this package locally for development:

kit install

This 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