gren-lang / gren-lang/compiler

Proposal: Add BigInt support to Gren for correct 64-bit integers and future-proof interop

Open
#364 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
503
Forks
29
PR merge metrics
No merged PRs in 30d

Description

Problem

Gren currently relies on Int, which maps to JavaScript Number and inherits its precision limits. This causes silent correctness issues in multiple important domains:

  • Binary formats (Protobuf, Cap’n Proto, etc.)
    • These formats natively support int64 / uint64
    • JavaScript Number cannot represent 64-bit integers exactly
    • Writing correct decoders today requires lossy conversions, strings, or hacks
  • Time (Posix)
    • Posix timestamps backed by Int are affected by the Year 2038 problem
  • Other common cases
    • IDs (Snowflake / database keys)
    • File formats, network protocols
    • Any exact integer arithmetic beyond 53 bits

Without BigInt, Gren cannot safely model many real-world data formats or interoperate losslessly with systems written in Rust, Go, C++, Java, etc.

Proposal
  • Introduce BigInt as a first-class type in Gren
  • Allow libraries (and potentially core types like Posix) to use BigInt where exact integers are required
  • Provide explicit conversion APIs between Int and BigInt when needed
Why BigInt?
  • Native JavaScript support (ES2020, widely available)
  • Exact integer semantics (no rounding or precision loss)
  • Eliminates string-based workarounds in decoders
  • Enables correct Protobuf / Cap’n Proto implementations
  • Solves the Year 2038 problem instead of postponing it
Compatibility
  • Internet Explorer does not support BigInt, but IE is deprecated and effectively unused in 2026
  • Now is still a good moment to introduce breaking changes (e.g. Posix) to APIs
Summary

Without BigInt, Gren cannot correctly represent 64-bit integers, which limits interop, correctness, and long-term viability. Adding BigInt support would unlock entire classes of libraries and make Gren safer and more future-proof by design.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Begin by mapping where Gren types and JavaScript interop are defined, then clarify BigInt semantics, conversions, and Posix compatibility before implementation. Done should include an agreed design and corresponding compiler and runtime coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, javascript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.