JakobDegen / mappable-rc

Rust crate providing mappable reference counted types
Apache License 2.0
9 stars 1 forks source link

Idea: Applicative functor? #1

Open lbfalvy opened 2 years ago

lbfalvy commented 2 years ago

This is a great crate, I've been using it extensively in my project to derive partially modified trees with minimal cloning. It is easily my favourite crate so far. That being said, I've been really missing the aiblity to derive a value from multiple Mrc instances, in a similar fashion to Haskell's applicative typeclass.

I realize that this isn't something reference counting pointers commonly support, so it may be out of scope for this project, but I think it would be a convenient addition so if you agree I'd happily introduce it into this crate. Alternatively, I would have to add mappable-rc's functionality to my crate, bound which encapsulates just the act of deriving an object from a reference to another, and was originally designed to enable persisting lock guards. It is currently possible to achieve the desired effect by using the two crates together, but it's very inefficient and requires a fair bit of boilerplate.

JakobDegen commented 2 years ago

I'm having trouble understanding the request. Can you give me a code example of what you're trying to do?