Mononym is a library for creating unique type-level names for each value in Rust.

Related tags

Utilities mononym
Overview

Mononym

Crates.io Documentation Apache licensed

Mononym is a library for creating unique type-level names for each value in Rust. The core type Named represents a named value of type T with a unique type Name as its name. Mononym guarantees that there can be no two values with the same name. With that, the Name type serves as a unique representation of a Rust value at the type level.

Mononym enables the use of the design pattern Ghosts of Departed Proofs in Rust. It provides macros that simplify the definition of dependent pairs and proof objects in Rust. Although there is still limited support for a full dependently-typed programming in Rust, Mononym helps us move a small step toward that direction by making it possible to refer to values in types.

Implementation Details

Examples

Here are a few examples sneak peek that are currently work in progress. Apologize for the lack of documentation for the examples. There will be in-depth tutorials that go through the example code and guide the readers on how to use mononym to define proofs.

You might also like...
Rust crate for creating filters with DirectX shaders. Includes Scale, Color conversion using DirectX api.

DxFilter Scale and ColorConversion done with DirectX filters. You can also create your own filters with the provided api. Crate contains various tools

 Creating CLI's just got a whole lot better.
Creating CLI's just got a whole lot better.

Staq Creating CLI's just got a whole lot better. Don't worry about CLI colouring, networking, Size of Executables, Speed ever again Have any doubts? R

🦊 An interactive cli for creating conventional commits.
🦊 An interactive cli for creating conventional commits.

🦊 koji An interactive cli for creating conventional commits, built on cocogitto and inspired by cz-cli. Installation Not yet. 😔 Usage Using koji # C

Another attempt at creating a wrapper for fastcdc in node.js

Another attempt at creating a wrapper for fastcdc in node.js. This time using wasmbindgen instead of neon.

A proc macro for creating compile-time checked CSS class sets, in the style of classNames

semester Semester is a declarative CSS conditional class name joiner, in the style of React's classnames. It's intended for use in web frameworks (lik

Concrete is a simple programming language specifically crafted for creating highly scalable systems that are reliable, efficient, and easy to maintain.
Concrete is a simple programming language specifically crafted for creating highly scalable systems that are reliable, efficient, and easy to maintain.

The Concrete Programming Language Most ideas come from previous ideas - Alan C. Kay, The Early History Of Smalltalk In the realm of low-level programm

CBOR (binary JSON) for Rust with automatic type based decoding and encoding.

THIS PROJECT IS UNMAINTAINED. USE serde_cbor INSTEAD. This crate provides an implementation of RFC 7049, which specifies Concise Binary Object Represe

An annotated string type in Rust, made up of string slices

A string type made up of multiple annotated string slices.

A tuple crate for Rust, which introduces a tuple type represented in recusive form.

tuplez This crate introduces a tuple type represented in recursive form rather than parallel form. Motivation The primitive tuple types are represente

Comments
  • Extendability problem

    Extendability problem

    Thanks for this wonderful library! I have played with it a bit, trying to apply to some simple but more realistic problems. What I found most frustrating is that I cannot figure out how to derive new proof with existing ones.

    Take the less_than_eq proof as an example:

    pub mod less_than_eq
    {
      use mononym::*;
    
      proof! {
        LessThanEq(x: u32, y: u32);
      }
    
      pub fn check_less_than_eq<XVal: HasType<u32>, YVal: HasType<u32>>(
        x: &Named<XVal, u32>,
        y: &Named<YVal, u32>,
      ) -> Option<LessThanEq<XVal, YVal>>
      {
        if x.value() <= y.value() {
          Some(LessThanEq::new())
        } else {
          None
        }
      }
    }
    

    And I want to add a simple function:

    pub fn at_most(x: u32, y: u32) -> u32 {
        if x <= y {
            x
        } else {
            y
        }
    }
    

    Ideally, I could write this function (with a LessThanEq<ZVal, YVal> proof) outside the less_than_eq module. However, what I finally struggled to achieve was something like this, inside less_than_eq module:

    pub struct ExistLessThanEq<
        ZVal: HasType<u32>,
        YVal: HasType<u32>,
    > {
        pub z: Named<ZVal, u32>,
        pub y: Named<YVal, u32>,
        pub less_than_eq: LessThanEq<ZVal, YVal>,
    }
    
    pub fn at_most(x: u32, y: u32, seed: Seed<impl Name>)
        -> ExistLessThanEq<impl HasType<u32>, impl HasType<u32>>
    {
        let (seed1, seed2) = seed.replicate();
        if x <= y {
            ExistLessThanEq {
                z: seed1.new_named(x),
                y: seed2.new_named(y),
                less_than_eq: LessThanEq::new(),
            }
        } else {
            ExistLessThanEq {
                z: seed1.new_named(y),
                y: seed2.new_named(y),
                less_than_eq: LessThanEq::new(),
            }
        }
    }
    

    Note that I have to repeat x <= y comparison here.

    I'm not quite familiar with dependently typed programing, but I believe there should be something better. Do you have any suggestions?

    opened by constituent 0
Owner
MaybeVoid
Functional Programming and Programming Language Theory
MaybeVoid
Translate C++/Rust type into C type with the same memory layout

clayout, translate C++/Rust type into C type with the same memory layout. Generally, clayout is used together with bpftrace. clayout is developed on d

盏一 11 Nov 17, 2022
Generate short, memorable phrases for throw-away names.

Generates three-word phrases of the form intensifier-adjective-noun, just like GitHub default repo names.

null 6 Dec 25, 2021
Simple procedural macros `tnconst![...]`, `pconst![...]`, `nconst![...]` and `uconst![...]` that returns the type level integer from `typenum` crate.

typenum-consts Procedural macros that take a literal integer (or the result of an evaluation of simple mathematical expressions or an environment vari

Jim Chng 3 Mar 30, 2024
Rust Stream::buffer_unordered where each future can have a different weight.

buffer-unordered-weighted buffer_unordered_weighted is a variant of buffer_unordered, where each future can be assigned a different weight. This crate

null 15 Dec 28, 2022
Derive with constructor for each field in struct.

A custom derive implementation for #[derive(with)] Get started 1.Generate with constructor for each field use derive_with::with; #[derive(with, Defau

SystemX Labs 4 Oct 22, 2023
Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust

Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust, and with an eye towards serializing runtime errors using serde.

Findora Foundation 1 Feb 12, 2022
A high level diffing library for rust based on diffs

Similar: A Diffing Library Similar is a dependency free crate for Rust that implements different diffing algorithms and high level interfaces for it.

Armin Ronacher 617 Dec 30, 2022
A low-level I/O ownership and borrowing library

This library introduces OwnedFd, BorrowedFd, and supporting types and traits, and corresponding features for Windows, which implement safe owning and

Dan Gohman 74 Jan 2, 2023
A playground for creating generative art, buit with Rust🦀 and WASM🕸

Genny A playground for creating generative art, buit with Rust ?? and WASM ?? About This is a simple playground that allows me to explore ideas around

João Paiva 3 Mar 12, 2022
A swiss army knife for creating binary modules for Garry's Mod in Rust.

A swiss army knife for creating binary modules for Garry's Mod in Rust.

William 38 Dec 24, 2022