Skip to content

Add support for accessing/projecting record type fields#2555

Open
Gabriella439 wants to merge 1 commit intomainfrom
gabriella/access_types
Open

Add support for accessing/projecting record type fields#2555
Gabriella439 wants to merge 1 commit intomainfrom
gabriella/access_types

Conversation

@Gabriella439
Copy link
Copy Markdown
Collaborator

No description provided.

@Gabriella439 Gabriella439 force-pushed the gabriella/access_types branch from 00b18b8 to a3ffd19 Compare December 3, 2023 04:30
@winitzki
Copy link
Copy Markdown
Collaborator

What are the conflicts in the git submodule dhall/dhall-lang? Should this branch get updated with the latest dhall-lang?

@winitzki
Copy link
Copy Markdown
Collaborator

This PR fails with the corner case that I was describing in the discussion here:

 { a : Bool, b : Text }.{}

{=}

 {  }.{}

{=}

If an empty field selection is applied to a literal record type, the result must be {}. In all other cases, the result must be {=}.

Comment thread dhall/src/Dhall/Eval.hs
@@ -414,6 +417,9 @@ vProjectByFields env t ks =
VRecordLit kvs ->
Copy link
Copy Markdown
Collaborator

@winitzki winitzki Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace:

if null ks
        then VRecordLit mempty
        else case t of

by

case t of
    VRecord _ | null ks -> VRecord mempty
     _        | null ks -> VRecordLit mempty

In this way, { a : Bool } . { } will be correctly reduced to { }.

@winitzki
Copy link
Copy Markdown
Collaborator

If this branch is too stale, I could prepare another branch with just the code changes (and no changes in the dhall/dhall-lang submodule).

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