fumieval / extensible

Extensible records, variants, structs, effects, tangles
BSD 3-Clause "New" or "Revised" License
128 stars 20 forks source link

Appending two anonymous records together #10

Closed mpickering closed 7 years ago

mpickering commented 7 years ago

Is it possible to provide a function which appends two anonymous records (which contain different fields) together?

fumieval commented 7 years ago

Yes, it used to have a concatenation function, but it has been removed when I changed the implementation to use SmallArray. Do you think that function is useful? I've never needed it

mpickering commented 7 years ago

I am writing benchmarks of different anonymous records libraries so I don't have any direct need for it if you don't want to include it in the API.

anton-dessiatov commented 7 years ago

Concatenation function is actually quite handy when using your library for plain extensible products.

I'm using extensible to pass a bunch of otherwise unrelated dependencies through my code. I have a bunch of small functions that require different services and need to combine them. Instead of defining a huge record type with everything I need and pass it around, I make all small functions polymorphic over an extensible product and sprinkle a bunch of 'Member' constraints (so that every small function requires only a small subset of services). Then I actually create extensible product filled with anything I might ever need and just pass it to my combined functions.

When actually creating that extensible product, concatenation gets quite useful! Please consider adding it to future releases.

fumieval commented 7 years ago

Shipped v0.4.5. Thanks @anton-dessiatov !