Skip to content

Mercury v0.1.0 - Initial Release

Latest

Choose a tag to compare

@lethalgem lethalgem released this 19 Jan 21:33
· 33 commits to main since this release

Mercury v0.1.0 - Initial Release

Mercury is a production-ready code generation tool that automatically generates PureScript type definitions and Argonaut JSON codecs from annotated Rust types.

Published Crates

Quick Start

Installation

# Install CLI globally
cargo install cargo-mercury-cli

Usage

# Generate PureScript types from Rust
mercury generate

Features

  • Automatic type conversion - Rust → PureScript type mapping
  • Full serde support - Handles rename_all, rename, skip, and other serde attributes
  • Type-safe JSON codecs - Generates Argonaut EncodeJson and DecodeJson instances
  • Cross-module imports - Automatically generates import statements for type dependencies
  • Advanced type mapping - Supports Option<T>, Vec<T>, DateTime, Uuid, and nested types
  • Multi-module organization - Outputs organized by source file structure
  • Deterministic output - Byte-for-byte identical on repeated runs (perfect for git)

📖 Documentation

Testing

  • 47 tests total (45 unit + 2 integration)
  • 100% pass rate
  • Comprehensive coverage of parser, codegen, and codec generation

📋 Type Mapping

Rust Type PureScript Type
i32, i64 Int
f32, f64 Number
bool Boolean
String String
Option<T> Maybe T
Vec<T> Array T
chrono::DateTime<Utc> String (ISO 8601)

🔧 Requirements

  • Rust 1.85+ (uses edition 2024 features)
  • PureScript 0.15+ (for frontend)
  • Spago (PureScript package manager)
  • Argonaut (PureScript JSON library)

Example

Rust:

use mercury_derive::mercury;
use serde::{Deserialize, Serialize};

#[mercury]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateUserRequest {
    pub user_name: String,
    pub email: String,
    pub is_active: bool,
}

Generated PureScript:

newtype CreateUserRequest = CreateUserRequest
  { userName :: String
  , email :: String
  , isActive :: Boolean
  }

instance decodeCreateUserRequest :: DecodeJson CreateUserRequest
instance encodeCreateUserRequest :: EncodeJson CreateUserRequest

Acknowledgments

Mercury was initially developed as part of Merchant Tech to solve the problem of keeping Rust backend types in sync with PureScript frontend types.

License

Licensed under:


Full Changelog: https://github.com/lethalgem/mercury/commits/v0.1.0