purescript / purescript-record

Functions for working with records and polymorphic labels
BSD 3-Clause "New" or "Revised" License
70 stars 31 forks source link

Homogeneous maps #22

Closed matthewleon closed 3 years ago

matthewleon commented 6 years ago

This is adapted from https://github.com/justinwoo/purescript-record-extra

I've changed a couple of things, adding the Homogeneous constraints and loosening the FunDeps a bit (please check if that makes sense).

Note that this depends on https://github.com/purescript/purescript-typelevel-prelude/pull/27

When that's merged, I'll update the bower file.

This is somewhat in response to the Issue here: https://github.com/purescript/purescript-record/issues/19

The last comment on there seems a bit ambiguous to me; I'm not sure if @paf31 wishes this kind of map to be kept in a separate repo or not... I do think having it here is quite handy. The next logical step after this would be maps and folds over labels and values, the latter of which would permit us to easily convert Records to, say, Maps, as has been discussed elsewhere.

paf31 commented 6 years ago

This is adapted from https://github.com/justinwoo/purescript-record-extra

I suggest mentioning this in the LICENSE file.

I'm not sure if @paf31 wishes this kind of map to be kept in a separate repo or not

I think a separate repo would be better, since you asked.

matthewleon commented 6 years ago

I'll create purescript-homogeneous-records and link that in here.

paf31 commented 6 years ago

That's just my opinion though, I'd like to hear what others think.

hdgarrood commented 6 years ago

I think we should merge this if we have a place in mind in the core libraries for where it would be used (but otherwise it's probably best as a separate repo outside of core). If we split maps as described in https://github.com/purescript/purescript-maps/issues/118 and move the current StrMap to a package in contrib, would there be anywhere else in core we would want to use this?

hdgarrood commented 6 years ago

Oh silly me, we were also talking about having the ability to construct a Map from a record too, weren't we? Never mind.

JordanMartinez commented 3 years ago

It sounds like the consensus above was to move this code to a separate repo unless we have a place in mind where we can use it. It also sounds like the map-like support for Records this PR adds should be done via a newtype because there are multiple instances one could have. This implements map for homogenous records, but my work in https://github.com/purescript/purescript-prelude/pull/268 shows it can be done for other kinds of records, too, which may be the same as or similar to what's already done in record-extra.

With that being said, should we close this PR?