Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax Trie variance #4338

Open
wants to merge 4 commits into
base: next-minor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pretty-trainers-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

`Trie<out A>` type annotations have been aligned. The type parameter was made covariant because the structure is immutable.
14 changes: 7 additions & 7 deletions packages/effect/src/Trie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type TypeId = typeof TypeId
* @since 2.0.0
* @category models
*/
export interface Trie<in out Value> extends Iterable<[string, Value]>, Equal, Pipeable, Inspectable {
export interface Trie<out Value> extends Iterable<[string, Value]>, Equal, Pipeable, Inspectable {
readonly [TypeId]: {
readonly _Value: Covariant<Value>
}
Expand Down Expand Up @@ -122,8 +122,8 @@ export const make: <Entries extends Array<readonly [string, any]>>(
* @category mutations
*/
export const insert: {
<V>(key: string, value: V): (self: Trie<V>) => Trie<V>
<V>(self: Trie<V>, key: string, value: V): Trie<V>
<V1>(key: string, value: V1): <V>(self: Trie<V>) => Trie<V | V1>
<V1, V>(self: Trie<V>, key: string, value: V1): Trie<V | V1>
} = TR.insert

/**
Expand Down Expand Up @@ -746,8 +746,8 @@ export const forEach: {
* @category mutations
*/
export const modify: {
<V>(key: string, f: (v: V) => V): (self: Trie<V>) => Trie<V>
<V>(self: Trie<V>, key: string, f: (v: V) => V): Trie<V>
<V1, V>(key: string, f: (v: V) => V1): (self: Trie<V>) => Trie<V1 | V>
<V1, V>(self: Trie<V>, key: string, f: (v: V) => V1): Trie<V | V1>
} = TR.modify

/**
Expand Down Expand Up @@ -807,6 +807,6 @@ export const removeMany: {
* @category mutations
*/
export const insertMany: {
<V>(iter: Iterable<[string, V]>): (self: Trie<V>) => Trie<V>
<V>(self: Trie<V>, iter: Iterable<[string, V]>): Trie<V>
<V1>(iter: Iterable<[string, V1]>): <V>(self: Trie<V>) => Trie<V | V1>
<V1, V>(self: Trie<V>, iter: Iterable<[string, V1]>): Trie<V | V1>
} = TR.insertMany
Loading