#category-theory #syntax-tree #encoding #ast #gadt #strict-encoding #ubideco

bin+lib strict_types

Strict types: confined generalized algebraic data types (GADT)

30 releases (18 stable)

2.8.1 Nov 16, 2024
2.7.2 Oct 31, 2024
2.7.0-beta.4 May 24, 2024
2.7.0-beta.2 Mar 12, 2024
1.0.0-rc.1 Mar 28, 2023

#230 in Parser implementations

Download history 800/week @ 2024-08-03 971/week @ 2024-08-10 2172/week @ 2024-08-17 927/week @ 2024-08-24 1861/week @ 2024-08-31 757/week @ 2024-09-07 1824/week @ 2024-09-14 572/week @ 2024-09-21 327/week @ 2024-09-28 451/week @ 2024-10-05 2180/week @ 2024-10-12 532/week @ 2024-10-19 953/week @ 2024-10-26 868/week @ 2024-11-02 805/week @ 2024-11-09 866/week @ 2024-11-16

3,502 downloads per month
Used in 30 crates (19 directly)

Apache-2.0

280KB
6K SLoC

Strict types AST and typelib implementation

Build Tests Lints codecov

crates.io Docs unsafe forbidden Apache-2 licensed

Protobufs for functional programming

This is a set of libraries for working with abstract syntax trees and libraries of strict types – type system made with category theory which ensures provable properties and bounds for the in-memory and serialized type representation.

Strict types is a formal notation for defining and serializing generalized algebraic data types (GADT) in a deterministic and confined way. It is developed with type theory in mind.

Strict Types are:

  • schema-based (with the schema being strict encoding notation),
  • semantic, i.e. defines types not just as they are layed out in memory, but also depending on their meaning,
  • deterministic, i.e. produces the same result for a given type,
  • portabile, i.e. can run on ahy hardware architecture and OS, including low-performant embedded systems,
  • confined, i.e. provides guarantees and static analysis on a maximum size of the typed data,
  • formally verifiabile.

To learn more about strict encoding read the spec.

Strict types works with type definitions. It allows:

  • static analysis of data types, like
    • defining semantic type ids;
    • specifying exact memory layout;
    • type equivalence in terms of semantics and memory layout;
    • size of serialized data
  • composing types into type libraries;
  • versioning type libraries basing on the semantic types;

The library allows to generate & compile strict type libraries (STL) from rust types implementing StrictEncoding trait -- and ensures that the deserialization with StrictDecode follows the same memory and semantic layout.

Strict Types Library

The library is able to reflect on itself, producing replica of its rust data types in strict types system.

Strict types library id: stl:9KALDYR8Nyjq4FdMW6kYoL7vdkWnqPqNuFnmE9qHpNjZ#lagoon-rodent-option

Import this lib by putting in the file header import lagoon_rodent_option_9KALDYR8Nyjq4FdMW6kYoL7vdkWnqPqNuFnmE9qHpNjZ as StrictTypes

Source code can be found in [stl/StrictTypes.sty] file.

Contributing

CONTRIBUTING.md

License

The libraries are distributed on the terms of Apache 2.0 license.

Dependencies

~3.5–4.5MB
~99K SLoC