Questions tagged [language-ext]

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

Language-ext github home page.

66 questions
1
vote
1 answer

LanguageExt functional Result for always-valid domain models

Problem Statement The World Feet Organization (WFO) has tasked me with calculating the sum of shoe sizes provided by client applications. The data sent to my API might contain invalid shoe sizes, such as negative values. My goal is to use…
jkbx
  • 414
  • 1
  • 6
  • 21
1
vote
1 answer

How do I convert an Either to Either with LanguageExt?

I have a method like this... public static async Task> GetCard(/* parameters */) => // code ommitted for clarity ...which I use like this (all parameters omitted for clarity)... public static async Task ActivateCard()…
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
1
vote
1 answer

How do I bind together multiple monads?

I'm using the TryAsync monad in LanguageExt, but am having difficulties trying to bind multiple ones together. I'm still learning functional programming, and so could be doing this completely wrongly. Please feel free to comment on any part of my…
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
1
vote
1 answer

Blazor component shows `Microsoft.AspNetCore.Components.RenderFragment` instead of the HTML content

I'm using the Language-Ext library to create a generic union type that represents one of three states... [Union] public interface LoadingOption { LoadingOption Loading(); LoadingOption Loaded(T value); LoadingOption
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
1
vote
1 answer

How to convert value of type IQueryable to Either>

Im using Either in a function with the signature public Either> Create(string userName), but when trying to return a result of type IQueryable I get a conversion error: Cannot implicitly convert type…
Robin
  • 1,170
  • 1
  • 10
  • 21
1
vote
2 answers

How do I convert a Validation to a string that's empty on success?

I'm fairly new at functional programming, and am trying to work within a very imperative code base, so I'm trying to write code that's mostly FP, but can't be fully. I have to write an override for the following method... protected override string…
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
1
vote
0 answers

Using the Unit type from MediatR and ReactiveUI (and language-ext)

I'm using MediatR alongside ReactiveUI - and both of them have the Unit type, and seems like they don't like each other: Everytime both namespace are imported (MediatR and System.Reactive), I need to use using to distinguish between them two…
GaryNg
  • 1,103
  • 9
  • 16
1
vote
1 answer

LanguageExt Fold list of eithers to one either

I have a function that performs a set of queries, each returning an Either. I collect these into a List<>. I want to fold these individual return values together so that the overall return result is a Either>. I…
Steztric
  • 2,832
  • 2
  • 24
  • 43
1
vote
1 answer

Refactoring method return value from async Task> to EitherAsync

I'm prototyping language-ext and functional code style for a web server library to share between my projects. I really like binding of async steps using LINQ query syntax but I have now encountered this compiler issue: language-ext Task of Either…
jussi.mattila
  • 227
  • 3
  • 16
1
vote
1 answer

Result is null exception from language-ext when working with monads

Why does this throw a "Result is null" exception? Shouldn't the None propagate through and set "a" equal to None? public void test() { Option a = match( from b in ReturnNull() select b, x => x, () => null …
Nick
  • 695
  • 8
  • 23
0
votes
3 answers

How can I extract the Exception from a faulted Result?

Please see code below, I am using the LanguageExt.Common.Result class: public async Task> DoSomething() { try { await Something(); return new Result(true); } catch (MyException ex) { …
acmoune
  • 2,981
  • 3
  • 24
  • 41
0
votes
0 answers

C# Error Handling with Language-ext using TryAsync and Bind methods

I've tried using TryAsync and Bind from Language-ext but haven't been successful. This is the closest I'm to achieving it. public virtual async Task Execute(SignDocumentCommand signDocumentCommand) { (await…
Omar
  • 374
  • 1
  • 14
0
votes
1 answer

LanguageExt - "Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement" in Either.Match

This is a follow-up to a question I asked earlier, but is (I think) much simpler, so I'm asking it separately. To clarify the question, I've stripped this one down even further. The code here uses the Language-Ext Nuget package. The only data…
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
0
votes
0 answers

C# LanguageExt Filter First

I am trying to use the LanguageExt library of C#. I wanted to know how to "Stop" filtering after the first predicate turns true in a set of objects. Example - HashMap with Filter through HashMap to find the FIRST element…
zooes
  • 1,280
  • 3
  • 15
  • 21
0
votes
0 answers

Casting Option to Option

Is there any simpler way to cast Option to Option than using Match and casting inside of it? This is the solution to casting that i am currently using: private Set Actors { get; } public SelectedData(Option actor) …
Amakazor
  • 29
  • 1
  • 3