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

Fix toMap type inference (and some merge tweaks) #671

Merged
merged 7 commits into from
Aug 3, 2019
20 changes: 12 additions & 8 deletions standard/type-inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -763,18 +763,22 @@ The `toMap` operator can be applied only to a record value, and every field
of the record must have the same type, which in turn must be a `Type`.


Γ ⊢ e :⇥ { x : T₀, xs… }
Γ ⊢ toMap { xs… } :⇥ List { mapKey : Text, mapValue : T₁ }
T₀ ≡ T₁
──────────────────────────────────────────────────────────
Γ ⊢ toMap e : List { mapKey : Text, mapValue : T₀ }
Γ ⊢ e :⇥ { x : T, xs… }
Γ ⊢ ( toMap { xs… } : List { mapKey : Text, mapValue : T } ) :⇥ List { mapKey : Text, mapValue : T }
philandstuff marked this conversation as resolved.
Show resolved Hide resolved
────────────────────────────────────────────────────────────────────────────────────────────────────
Γ ⊢ toMap e : List { mapKey : Text, mapValue : T }


Γ ⊢ e :⇥ {} Γ ⊢ T₀ :⇥ Type T₀ ⇥ List { mapKey : Text, mapValue : T₁ }
─────────────────────────────────────────────────────────────────────────
Γ ⊢ ( toMap e : T₀ ) : List { mapKey : Text, mapValue : T₁ }


Γ ⊢ toMap e : T₀ T₀ ≡ T₁
──────────────────────────
Γ ⊢ ( toMap e : T₁ ) : T₁


## Unions

Union types are "anonymous", meaning that they are uniquely defined by the names
Expand Down Expand Up @@ -859,9 +863,9 @@ between the fields of the handler record and the alternatives of the union:
Γ ⊢ (merge t u : T) : T


Γ ⊢ t :⇥ { ts… } Γ ⊢ merge t u : T
──────────────────────────────────── ; `ts` non-empty
Γ ⊢ (merge t u : T) : T
Γ ⊢ merge t u : T₀ T₀ ≡ T₁
────────────────────────────
Γ ⊢ (merge t u : T) : T


Γ ⊢ t :⇥ { y : ∀(x : A₀) → T₀, ts… }
Expand Down
1 change: 1 addition & 0 deletions tests/type-inference/success/unit/ToMapAnnotatedA.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
toMap { foo = 1, bar = 4, baz = 9 } : List { mapKey : Text, mapValue : Natural }
1 change: 1 addition & 0 deletions tests/type-inference/success/unit/ToMapAnnotatedB.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
List { mapKey : Text, mapValue : Natural }