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

Change how dhall repl handles prior definitions #729

Merged
merged 1 commit into from
Dec 2, 2018

Conversation

Gabriella439
Copy link
Collaborator

The motivation for this change is so that more code type-checks
within a REPL session.

For example, before this change the following session fails:

 :let Either = λ(a : Type)  λ(b : Type)  < Left : a | Right : b >
 :let Example = < Left : Natural | Right : Bool >

Example : Type

 Example.Left

Example : Type

Error: Not a record or a union

Example.Left
(stdin):1:1

After this change, the same session works:

 :let Example = < Left : Natural | Right : Bool >

Example : Type

 Example.Left

λ(Left : Natural)  < Left = Left | Right : Bool >

The difference is in how we incorporate prior definitions when
type-checking code. Before this change prior definitions were added
to the context, which leads to type-checking failures because type
synonyms don't work when used in this way. After this change we
incorporate them as extra let definitions (same as normalization).

The motivation for this change is so that more code type-checks
within a REPL session.

For example, before this change the following session fails:

```haskell
⊢ :let Either = λ(a : Type) → λ(b : Type) → < Left : a | Right : b >
⊢ :let Example = < Left : Natural | Right : Bool >

Example : Type

⊢ Example.Left

Example : Type

Error: Not a record or a union

Example.Left
(stdin):1:1
```

After this change, the same session works:

```
[⊢ :let Example = < Left : Natural | Right : Bool >

Example : Type

⊢ Example.Left

λ(Left : Natural) → < Left = Left | Right : Bool >

```

The difference is in how we incorporate prior definitions when
type-checking code.  Before this change prior definitions were added
to the context, which leads to type-checking failures because type
synonyms don't work when used in this way.  After this change we
incorporate them as extra `let` definitions (same as normalization).
@Gabriella439
Copy link
Collaborator Author

cc: @basile-henry since you may have run into this issue when testing union alternative completion in #727

@basile-henry
Copy link
Collaborator

@Gabriel439 I have ran into this! It was late and I thought I didn't know how to properly setup union types.
Thanks for fixing it! 😄

@Gabriella439 Gabriella439 merged commit 56d795d into master Dec 2, 2018
@Gabriella439 Gabriella439 deleted the gabriel/repl_let branch December 2, 2018 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants