-
Notifications
You must be signed in to change notification settings - Fork 217
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
Restore support for records containing both types and terms #1173
Restore support for records containing both types and terms #1173
Conversation
This makes sense to me so far – but I don't know much about these things. I think you should probably also adjust the typechecking for
|
Thanks @sjakobi - I wasn't sure if that was explicitly checked in the type checker. I'll have a look and update that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good so far, just one comment
This is getting there, but I'm stuck on what to do with one test case. The test input is: { x = Type, y = Kind } Which does have a type - it has type { x : Kind, y : Sort } However, the current test harness can't actually verify this, because the expected type is itself type checked, and Should I reject |
@ocharles: Yes, I believe you would need to reject records that contain fields set to |
Thanks for the clarification - I'll see what I can do. |
Nice! Did you see this issue: dhall-lang/dhall-lang#558 ? It might be nice to put it in with this change, but we can always take care of it in a separate PR too – up to you. |
…tore-mixed-records
…askell into restore-mixed-records
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make sure the full acceptance testsuite passes, before you merge dhall-lang/dhall-lang#689?
dhall/src/Dhall/TypeCheck.hs
Outdated
|
||
kts <- Dhall.Map.unorderedTraverseWithKey process kvs' | ||
_ <- loop ctx recordType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check necessary? If it is necessary, do we have a test for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's required by the standard, but it might be redundant now that we permit mixed records. In other words, this additional check required by the standard might not actually catch anything that the other checks do so there wouldn't be a differentiating test, but the standard would need to be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way I'll remove it as I'm reasonably sure it's no longer necessary and the standard change can follow
dhall/src/Dhall/TypeCheck.hs
Outdated
@@ -546,19 +527,15 @@ typeWithA tpa = loop | |||
_ -> Left (TypeError ctx e (MustCombineARecord '∧' kvsY tKvsY)) | |||
|
|||
ttKvsX <- fmap Dhall.Core.normalize (loop ctx tKvsX) | |||
constX <- case ttKvsX of | |||
_ <- case ttKvsX of | |||
Const constX -> return constX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just return ()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is this check necessary at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not necessary any longer, so I'll remove it. One invariant of the type system is that the type of the type of something will always be a type-checking constant (i.e. Const
) so if we don't care about the specific constant then we no longer need to check this
dhall/src/Dhall/TypeCheck.hs
Outdated
Const constX -> return constX | ||
_ -> Left (TypeError ctx e (MustCombineARecord '∧' kvsX tKvsX)) | ||
|
||
ttKvsY <- fmap Dhall.Core.normalize (loop ctx tKvsY) | ||
constY <- case ttKvsY of | ||
_ <- case ttKvsY of | ||
Const constY -> return constY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
dhall/src/Dhall/TypeCheck.hs
Outdated
@@ -621,19 +590,15 @@ typeWithA tpa = loop | |||
_ -> Left (TypeError ctx e (MustCombineARecord '⫽' kvsY tKvsY)) | |||
|
|||
ttKvsX <- fmap Dhall.Core.normalize (loop ctx tKvsX) | |||
constX <- case ttKvsX of | |||
_ <- case ttKvsX of | |||
Const constX -> return constX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments as for Combine
.
…/dhall-haskell into circuithub-restore-mixed-records
... as suggested by @sjakobi
... as caught by @sjakobi I will also upstream this into the standard
... as caught by @sjakobi
... as caught by @sjakobi
@ocharles: I opened a pull request against your branch to fix the test failure and address the review feedback: circuithub#1 |
Address review feedback for mixed records pull request
Thanks for that! It was a little hard to do the review but I trust you and
am not too invested in how this work is done - the standard and
understanding the changes was more important to me. As such, I've just gone
ahead and merged your PR. Also, I'm not sure if you're aware but GitHub
will let you push changes directly to my branch, so feel free to push more
fixes directly here. I will also try and help next week to push this over
the line.
Cheers!
…On Sat, 31 Aug 2019, 5:36 pm Gabriel Gonzalez, ***@***.***> wrote:
@ocharles <https://github.com/ocharles>: I opened a pull request against
your branch to fix the test failure and address the review feedback:
circuithub#1 <circuithub#1>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1173?email_source=notifications&email_token=AAAFDDUTLJNR2XIWNLJ5DNTQHKMZHA5CNFSM4IH3K7SKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5TQKIQ#issuecomment-526845218>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAFDDXDCE25FR2ILQV7IGLQHKMZHANCNFSM4IH3K7SA>
.
|
... as standardized in dhall-lang/dhall-lang#689