Comments (2)
Instead of introducing a whoe batch of new methods (Tap
, TapAsync
, TapErr
, TapErrAsync
, ...), I strongly believe in function composition. The side-effects like logging are often actions as in returning void instead of a value - which is impossible to compose. Depending on your exact code, you should easily get away with a private helper to handle the "execute the action and return the given value". If that's not the case, a more generic Do
higher-order function can work for you.. something like
public static T Do<T>(Action<T> action)
{
return x => {
action.Invoke(x);
return x;
};
}
I still am unsure whether we'd want stuff like this in Galaxus.Functional - there're many similar nice helpers, but they don't flow that well in actual production code I think.
from galaxus.functional.
While we didn't call it Tap(...)
(we followed the naming suggestion from Scott Wlaschin), we used to have a very similar extension method in our code to handle this. Since then the code calling the extension method changed and we no longer need this extension anymore, but as Scott states in his talk, Railway oriented programming (https://fsharpforfunandprofit.com/rop/), handing over a value to a method returning void is a quite common need. How about we add Tap(...)
, Tee(...)
, or whatever we want to call it, directly to the types and move all separate concerns (e.g. async) to their own project, as suggested here: #25?
from galaxus.functional.
Related Issues (20)
- Enforce (?) code style
- Implementation of FirstOrNone, LastOrNone and SingleOrNone are not Lazy. HOT 3
- Consider an Option.Some constructor relying on type inference. HOT 3
- Build produces a lot of documentation warnings HOT 1
- .IsA / .IsB / .SelectA / .SelectB for Either<A, B>
- Add async support for Either2.Match and Either3.Match HOT 1
- Option-Type value getter for dictionaries
- Option to Either HOT 1
- Naming of AttemptToUnwrapNoneWhenOptionContainedSomeException HOT 3
- Extract async-extensions into their own "module" HOT 2
- Allow pattern-matching on Option, Result and maybe even Either
- Add NUnit Testing Extensions HOT 1
- Introduce MatchAsync method for Option HOT 3
- Polish package packing process
- Add async Option.MapOr and Or
- Add Option.MapOrElse HOT 1
- Add Result.FlatMap HOT 1
- Add a way to convert an Option<T> to an Either<A, T> HOT 2
- ConfigureAwait(false) for async extensions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from galaxus.functional.