Questions tagged [language-ext]

Relating to the open-source C# functional framework: language-ext.

Language-ext github home page.

66 questions
0
votes
0 answers

Is there a way of passing extra data to the Left lambda in Match without having to add it to every intermediate method?

Suppose I have a method that takes the Id of a card issuer (think of loyalty cards for shops), and I want to get the status of the customer who made the most recent transaction. Yes this is a silly scenario, but it's easer than trying to describe…
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
0
votes
1 answer

Get Right value from LanguageExt c#

I have method that returns: Either result = GetResult(); I need to return right value: (int NextDelayMs, int NextRetryCount) But I can't figure out how to do it. I tried: var toReturn = result.Map(x => x.Right); but…
user122222
  • 2,179
  • 4
  • 35
  • 78
0
votes
0 answers

Unwrapping multiple TryAsync

cIn haskell i can have : do result1 <- IOaction1 result2 <- IOaction2 doSomethingWith result1 result2 How can i achive this in C# with LanguageExt ? Edit EitherAsync x = TryAsync(new…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
0
votes
0 answers

How to use switch on the value with an Option?

I am using LanguageExt but I suspect the same question applies to other FP languages. I got myself in the situation below and would love to have some advice: Check the value in an Option Depending on the value, a different function is applied The…
DavidY
  • 357
  • 5
  • 15
0
votes
1 answer

How do I extract the value from a LanguageExt Validation?

I am learning about LanguageExt and using functional programming styles in C#. I have created a new class, with my goal being a ValueObject: public sealed class AlertDefinition : NewType { private…
TortillaCurtain
  • 501
  • 4
  • 18
0
votes
1 answer

Call Langext MapAsync only if Option is Some value and not None

I use LangExt library and i have the case of no user exists with UserId 1. public async Task GetUser() => await GetUser(1) .MapAsync(this.alterName) .MapAsync(this.alterCountry) …
EagerToLearn
  • 89
  • 12
0
votes
1 answer

Language-ext: chain Either with Option?

I am just starting with language-ext, trying to use it in my Azure Function. In this function, I first parse/validate the POSTed data from the HTTP request using some validator. This validator returns an Either. Then…
Para Jaco
  • 211
  • 2
  • 9
0
votes
1 answer

Language-ext Aggregate exceptions/failures when Try>>

I am fresh new with the brilliant language-ext c# library. I have this code that returns a Try> object: Try(DetectAlertsToNotify) .MapT(SendNotification) //treat errors happened indifferently…
maxence51
  • 994
  • 1
  • 8
  • 20
0
votes
2 answers

Functional Programming in C# with Language-ext

I have recently started working on a new DotNet Core project. I had noticed that someone (developer) used the Language-Ext library in this project. It was a new thing for me so I got to know that it is for Functional programming. It was quite…
KiddoDeveloper
  • 568
  • 2
  • 11
  • 34
0
votes
1 answer

LanguageExt: How do I do the equivalent of Option.Match with a [Union]?

I want to create a union that will act a bit like Option, but that allows a 3-way state, rather than a 2-way state. The reason for this is to use it when loading data from a database. If I were doing this with an Option, I would do something…
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
0
votes
1 answer

Return IEnumerable of a property of the Key in a Map

Suppose I have the following classes: public class X { public string a; public string b; } public class Y { public string c; } and I have a Map: var myMap = Map(); How do I return a list of a (IEnumerable) from this? I am…
joe_maya
  • 185
  • 1
  • 7
0
votes
1 answer

Language-Ext Unions - Target runtime doesn't support default interface implementation

I'm trying to user the Union type in Language-Ext and am getting error: "Target runtime doesn't support default interface implementation" for the method name and "The type or namespace name 'InconsistentFirstName' could not be found" My code looks…
Dennis
  • 31
  • 9
0
votes
2 answers

LangageExt: Chaining of two Eithers with Bind(), but cannot figure out how to use them to create another Either

I am using LanguageExt to have functional programming features in C#. I have a method in which I want to build an instance of VaultSharp to access our HashiCorp Vault service. My goal is to create an instance of VaultClientSettings (see methods…
0
votes
1 answer

How to bind on multiple Either<,>?

I have two functions that return Either, and the 2nd function depends on the first one. Either either1 = ReturnEither1(...); Either either2 = either1.Bind(ReturnEither2); Now, I have a 3rd function which depends on…
David S.
  • 10,578
  • 12
  • 62
  • 104
0
votes
1 answer

Convert Either> to Option> in c# LanguageExt

I'm using C# LanguageExt https://github.com/louthy/language-ext I have a class MyDto parsed from some Json. The parsing functions returns Either. If the dto matches a given rule, or it is an error, then I would like to get back the…