All Questions
Tagged with functional-programming c#
38 questions
0
votes
2
answers
481
views
How to Represent Functional Boolean
.NET Boolean type usually makes if else pair all over the code.
Functional Boolean should be more like Either type. Ideally represented as Either<Unit, Unit>.
However, my issues with Either type ...
16
votes
6
answers
8k
views
What is the functional-programming alternative to an interface?
If I want to program in a "functional" style, with what would I replace an interface?
interface IFace
{
string Name { get; set; }
int Id { get; }
}
class Foo : IFace { ... }
Maybe a Tuple<&...
0
votes
2
answers
376
views
C# coding style, functional approach
I have thought of this for a while and I want to know what you think about this.
This is more of a way to structure the code that might not be 100% object oriented and that is not the purpose. I would ...
9
votes
7
answers
4k
views
what can go wrong in context of functional programming if my object is mutable?
I can see the benefits of mutable vs immutable objects like immutable objects take away lot of hard to troubleshoot issues in multi threaded programming due to shared and writeable state. On the ...
1
vote
0
answers
156
views
How to improve maintainability and testability of a service by refactoring it into a functional style
A customer of ours has a rather large (500+ LOC) service as central part of the project. Written in C# and consisting of rather clunky large imperative style functions, I was asked to improve the test ...
12
votes
4
answers
3k
views
Why usage of assignment operator or loops discouraged in functional programming?
If my function meets the two requirements listed below, I believe that the function Sum returns the summation of the items in a list, where item evaluates as true for a given condition. Doesn't this ...
4
votes
2
answers
297
views
Function that returns non parameter functions
I found a function in c# like this:
private Dictionary<string, Func<string>> ObtenerExtraCfgCampo(MsgDefCamp camp)
{
var extra = new Dictionary<string, Func<string>&...
1
vote
0
answers
417
views
Should I use "Map" or "Select" for new functor-like operators in C#?
I'm designing a type in C# that will be used as an algebraic type in a functional style, but is not a collection type and does not implement IEnumerable. If this type is a Functor, should I name its ...
4
votes
2
answers
2k
views
What is control abstraction in the context of functional programming?
I understand concept data abstraction as it is relevant to OO programming. However on contrary it seems Function Programming promotes or makes use of concept control abstraction.
I tried searching ...
1
vote
2
answers
251
views
Functional programming: does using a generic make a function impure?
public static Func<string, Task<T>> MyMethod<T>(
UserCredentials credentials,
Func<string, string, string, Task<T>> func
) =>
async (value) ...
-2
votes
2
answers
2k
views
What does it mean to "wrap" a stored procedure?
My manager has asked me to "just wrap the stored procedure".
The requirements are to create a microservice that will do the following:
Accept parameters from the user.
Pass those parameters to the ...
7
votes
1
answer
5k
views
Is there a better term for "functional method chaining"?
I'm writing a C# style guide for my team and I'm trying to describe the benefits of side-effect-free functional-style methods. I want to include online references to back up the suggestions, but I can'...
17
votes
4
answers
3k
views
When programming in Functional style, do you have a single application state that you weave through the application logic?
How do I construct a system that has all of the following:
Using pure functions with immutable objects.
Only pass into a function data that the function it needs, no more (i.e. no big application ...
0
votes
1
answer
608
views
Why isn't it common to hack partial function application in C#?
In many ways C# supports functional programming, but there is a (shrinking) list of features commonly found in statically-typed functional languages that are missing, such as tail recursion, partial ...
24
votes
4
answers
12k
views
Should functions that take functions as parameters, also take parameters to those functions as parameters?
I often find myself writing functions that look like this because they
allow me to easily mock data access, and still provide a signature that accepts parameters to determine what data to access.
...