Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

glue Rec's #58

Closed
Pitometsu opened this issue Jun 16, 2020 · 3 comments
Closed

glue Rec's #58

Pitometsu opened this issue Jun 16, 2020 · 3 comments

Comments

@Pitometsu
Copy link

Pitometsu commented Jun 16, 2020

Any type family to .+ Rec's, not Row's only?
(Or to get Row type of Rec type)

@dwincort
Copy link
Collaborator

Are you looking for something like:

type family (l :: *) .* (r :: *) :: * where
  Rec l .* Rec r = Rec (l .+ r)
  x .* y =  TypeError (TL.Text "Tried to .* non-records")

No, I haven't included anything like this in row-types because .+ seemed general enough, and having another operator just for records seemed unnecessary. Do you have a particular use-case in mind?

@Pitometsu
Copy link
Author

Pitometsu commented Jun 17, 2020

Do you have a particular use-case in mind?

Yes, following steps.
Create alias to record, to use it everywhere.
Now it's expected to have an ability to create type alias to helper record with additional fields without defining intermediate type alias of rows of original type.

@dwincort
Copy link
Collaborator

I suppose I can see the usefulness of this — I've definitely made a row-type synonym called FooRow just so I can then define Rec FooRow — but I think it may make things more confusing overall because now different row-types type families will work on different kinds of arguments. That is, other type functions like .\, .!, .-, Extend, etc, all work on row-types themselves, and not on Recs over row-types, and .* won't play nicely with them. One might argue that we should add special Rec versions of all of those type functions too, but I'm not ready to go there (maybe if they were all in a separate module, e.g. Data.Row.Record.TypeFamilies, but still, I'm not sure it's sensible).

For now, I encourage you to use the 3-line .* I suggested above in your own row-types code. If you find that it's actually super-useful and you're using it a lot, maybe we can discuss upstreaming it later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants