Skip to content

Couldn't match type ListTable Result (SomeData Result) with [SomeData Result] #321

Closed

Description

@abigailalice

I encountered this type error recently while trying to store a ListTable within one of my table schemas, defined sort of like

data SomeTable f = SomeTable
    { someId :: Column f SomeId
    , nested :: ListTable f (SomeData f)
    }

This was kind of confusing, as I'd assumed these were the same types. I was still able to get my code to work, simply by splitting up the SomeTable data type into its individual fields after selecting it with each, and returning them in a tuple, rather than in the SomeTable constructor.

My main question is is this working by design, or something preventing type inference, or something else? I've used many plenty to returned nested tables, and never encountered any issues, which is why I thought the types were equivalent. Though this is the first time I've ever stored a ListTable within a schema, which seems relevant, since it's only when I tried to work with a SomeTable Result that the ListTable Result stopped being a list.

Activity

  1. ocharles commented on Apr 17, 2024

    @ocharles
    Contributor

    If you want to store a List table in a Rel8able, try using HList. That has special support for using ListTable with Expr and [] with Result. Does that help?

  2. abigailalice commented on Apr 17, 2024

    @abigailalice
    ContributorAuthor

    Yeah, that seemed to work, though I'm still left wondering why tupling the ListTable didn't experience the same problem. But I suppose it's not really important as long as I know how to avoid it. Thanks.

  3. ocharles commented on Apr 17, 2024

    @ocharles
    Contributor

    It's unfortunately very difficult to make what you want work. If we have a Query (ListTable expr a), we really want the result here to be a [a'] - having to work through some other list type would (imo) kinda suck. So this means we need ListTable to select into []. But in your record, that ListTable appears without any wrapping, which means we can't make the same mapping. This is why it tries to produce a ListTable Expr, but that's contradictory (because a Foo Expr Rel8able has to select to Foo Result). So unfortunately this is all rather "due to technical reasons", which I never like as an answer... But this is the best solution we know about for now!

  4. abigailalice commented on Apr 20, 2024

    @abigailalice
    ContributorAuthor

    I guess I'll close this then, I did find the stuff in the documentation in HList mentioning storing it in tables. I might work on adding examples of things like this to the cookbook.

  5. locked and limited conversation to collaborators on Apr 25, 2024
  6. converted this issue into a discussion #322 on Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions