gren-lang / gren-lang/compiler
Proposal: Add BigInt support to Gren for correct 64-bit integers and future-proof interop
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
Numbercannot represent 64-bit integers exactly - Writing correct decoders today requires lossy conversions, strings, or hacks
- These formats natively support
- Time (
Posix)Posixtimestamps backed byIntare 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
BigIntas a first-class type in Gren - Allow libraries (and potentially core types like
Posix) to useBigIntwhere exact integers are required - Provide explicit conversion APIs between
IntandBigIntwhen 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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