racket / racket/typed-racket

Typed Racket pretends mutable sets don't exist, and yet it assumes all hashtables could be mutable

Open
#32 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
575
Forks
106
Avg merge
2h 1m
Merged PRs (30d)
2

Description

Typed Racket only provides types for immutable set operations. It would be painless to add types for mutable operations as well, but TR also considers Setof types to be covariant, which obviously isn't true with mutable sets.

This is inconsistent with how TR handles hashtables. In an ideal world, I'd like HashTable to be immutable and have a separate MutableHashTable for mutable hash tables and mutable operations. This would be nice for a number of reasons:

  • This would let hashtables be covariant.
  • This would make contracts on immutable hashtables flat contracts, so predicate generation and occurrence typing would work with them.
  • Mutability would need to be explicitly noted in the type system.

I'd unfortunately guess that this is not possible to change at this point. Still, the behavior with sets and hashtables are inconsistent. If we can't change HashTable, can we make MutableHashTable and ImmutableHashTable subtypes? Then could we make the equivalent variations for sets?

Contributor guide

No contributing guide indexed for this repository

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. Start by locating Typed Racket's set and hashtable type definitions and their variance handling. Done would require an agreed design for mutable and immutable collection types, plus corresponding operations and tests.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.