Implement tee/tap for functors?
See original GitHub issueThe generic iter
takes a functor and an action to perform, and returns unit
.
I’d like a similar function that passes through the functor, i.e. performs a unit
-returning action and then returns the original input (for further chaining). As I understand it, this is typically called tee
or tap
. Could this be added?
Le me know if this is unclear and I should provide more details.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Azure functions debug fails to start on a non-trivial project
When I create new Azure Functions project (.NET 5 isolated) right from the start debugging it works fine. But after some code changes ......
Read more >Why is the constant always dropped from big O analysis?
Multiplying a function by a constant only influences its growth rate by a constant amount, so linear functions still grow linearly, logarithmic ...
Read more >Keep your app visible on Wear
For apps that require more frequent updates, use an AlarmManager object to wake the processor and update the screen more frequently. To ...
Read more >Individual or group. (27 Responses)
The use of the term "protection functions" is not a defined NERC term and ... An example would be for a tee-tap off...
Read more >Japan high-tech "washlets" aim at U.S. bottoms
The name belongs to its product line Washlet, but is used in Japan as a generic term for all high-tech toilets with bidet...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cmeeren Sorry about my poor explanation, here’s a (hopefully) better attempt.
Result<'T,'U>
(read 'T and 'U as variable types) is a bifunctor, as I can map a('T -> 'A)
and a('U -> 'B)
and get a "bimapped"version of it.Now,
Result<'T,unit>
(unit or another fixed type) is not, because I can’t map any function to the right side, I could only map aunit->unit
function, otherwise I would end up with a different type.@wallymathieu I think
tap
is also used in Scala.@cmeeren well, the composition is backwards
map << tee
but you’re right in that it won’t be efficient.An easy alternative is
let inline ftee f x = iter f x; x