Python dataclass equivalent

This page summarizes the projects mentioned and recommended in the original post on /r/Clojure

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • truss

    Assertions micro-library for Clojure/Script (by taoensso)

  • I haven't tried it myself. I generally just use truss for runtime constraint checking. I use a modified version that integrates scope-capture. And malli validation for more complex cases, but I try to limit that. For me it is better to validate individual attributes as needed, vs validating an entire "type"/collection of attributes. So each function only cares about the attributes that it needs, and validates only as needed.

  • scope-capture

    Project your Clojure(Script) REPL into the same context as your code when it ran

  • I haven't tried it myself. I generally just use truss for runtime constraint checking. I use a modified version that integrates scope-capture. And malli validation for more complex cases, but I try to limit that. For me it is better to validate individual attributes as needed, vs validating an entire "type"/collection of attributes. So each function only cares about the attributes that it needs, and validates only as needed.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • ghostwheel

    Hassle-free inline clojure.spec with semi-automatic generative testing and side effect detection

  • if all you care about is information / documentation, and maybe validation, then spec or malli are fine. using spec during runtime to simulate a type system is a poor choice in most cases, because you are doing runtime type checking (something akin to dependent types or even esoteric contracts that are hard/impossible to express statically). There are some libs that help bolt a typed facade (using spec) onto the familiar defn / fn, https://github.com/gnl/ghostwheel https://github.com/Provisdom/defn-spec .

  • defn-spec

    Add function args and return Spec checking via assertions

  • if all you care about is information / documentation, and maybe validation, then spec or malli are fine. using spec during runtime to simulate a type system is a poor choice in most cases, because you are doing runtime type checking (something akin to dependent types or even esoteric contracts that are hard/impossible to express statically). There are some libs that help bolt a typed facade (using spec) onto the familiar defn / fn, https://github.com/gnl/ghostwheel https://github.com/Provisdom/defn-spec .

  • spec-tools

    Clojure(Script) tools for clojure.spec

  • I like spec-tools data specs. I never got into schema, although I was aware of it. spec came along and swept a substantial portion of the crowd (I think the interleaving of parsing and regex style operators is slick/useful). Malli looks excellent though, and I think it's worthy of learning. I have no opinion on spec2 as of yet.

  • datascript

    Immutable database and Datalog query engine for Clojure, ClojureScript and JS

  • Meta comment: Many complex tree shapes are actually projections of a graph. Graphs are shapeless and normalized; it is the query that projects the graph into tree shapes that are denormalized. Thus massive python/java nested OO data models with rigid and denormalized shapes can be collapsed into a flattened, normalized graph. Do you have a graph? Clojure has easy graph data structures through https://github.com/tonsky/datascript

  • plumbing

    Prismatic's Clojure(Script) utility belt

  • This library https://github.com/plumatic/plumbing, a predecessor of spec, has variants of defn and fn that allow you to specify the schema inline, sort of similar to type hints.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts