purescript / purescript-record

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

Builder Profunctor instance #32

Closed matthewleon closed 6 years ago

matthewleon commented 6 years ago

There should be a Profunctor instance for Builders.

hdgarrood commented 6 years ago

I'm not sure this is doable, actually. The problem is that, as I understand it, a Builder a b is a function a -> b which is guaranteed to use its argument exactly once, but allowing you to lmap with any old function could break that guarantee. I've haven't been able to come up with an example of this breaking things yet but I expect it can be done.

@paf31 does this sound reasonable?

matthewleon commented 6 years ago

@hdgarrood I see what you're saying.

paf31 commented 6 years ago

Something like lmap (const r) builder seems like it would cause trouble by modifying the immutable record r.