May 18, 2026

When code couples need therapy

Show HN: Hsrs – Type-Safe Haskell Bindings Generator for Rust

A clever bridge between two coding worlds has fans cheering and skeptics side-eyeing the fine print

TLDR: Hsrs is a new tool that lets Rust code be used from Haskell with much of the hard connection work generated automatically. Commenters loved the idea as a possible boost for Haskell’s smaller tool ecosystem, but skeptics quickly warned that memory handling could turn the dream into drama.

A new project called hsrs just strutted onto Show HN promising something that sounds almost magical: write code in Rust, press a button, and get clean Haskell wrappers so the two languages can work together without the usual manual glue work. In plain English, it aims to make one programming language call into another more safely, while handling memory cleanup and data conversion behind the scenes. For developers who live in the very-online world of "strongly typed" languages, this is basically catnip.

And the comments? Instant hopeful hype, followed by reality-check energy. One early reaction was pure optimism: could this help Haskell piggyback on Rust’s fast-growing library scene and give Haskell users access to more tools? That’s the dream, and commenters clearly felt it. But then the mood swerved into the classic nerd-drama combo of admiration plus dread. Another commenter basically said: yes, this is lovely in theory, but garbage collection is where the romance gets messy. Translation for normal humans: both languages manage memory differently, and that can turn a neat idea into a headache.

That tension became the whole vibe of the thread: "Finally, typed languages can talk!" versus "Sure, until the memory systems start fighting in the parking lot." There weren’t many full-on dunks, but there was definitely that familiar Hacker News flavor of polite applause wrapped around a warning label. The funniest part is how fast the conversation jumped from "cool tool!" to an existential debate about whether programming languages can ever truly be friends.

Key Points

  • Hsrs generates type-safe Haskell FFI bindings from annotated Rust code using macros such as `#[hsrs::module]`, `#[hsrs::data_type]`, `#[hsrs::value_type]`, `#[hsrs::enumeration]`, and `#[hsrs::function]`.
  • The workflow consists of annotating Rust code, running `hsrs-codegen` to produce a Haskell module, and then importing and using the generated bindings in Haskell.
  • The generated bindings manage opaque Rust-owned data with `ForeignPtr` and serialize complex values across the FFI boundary using Borsh.
  • Hsrs maps common Rust types into Haskell equivalents, including `Result<T, E>` to `Either E T`, `Option<T>` to `Maybe T`, `Vec<T>` to Haskell lists, and `String` to `Text`.
  • The article notes a platform limitation: `usize` and `isize` are mapped to 64-bit Haskell types, which matches x86_64 and aarch64 but may truncate values on 32-bit targets.

Hottest takes

"Really cool nice job!" — rienbdj
"could this be a way to expand the Haskell ecosystem?" — rienbdj
"the GC will probably cause some friction" — _flux
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.