Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jorge E. Alvarez
    @jealvarez
    Hi
    I'm very new with language-ext
    so, I was wondering how to do
    the following
    I have
    TryAsync<Option<Application>> tryAsync = async () => await _applicationDao.SaveAsync(application);
    so, I would like to map it to
    Task<Either<IError, Application>>
    but I don't know how to do it
    thanks in advance
    Jorge E. Alvarez
    @jealvarez
    @here
    Nikita Ilyin
    @nike61
    Is it possible to use Arr with BinaryFormatter.Serialize? I'm getting "Field in TypedReferences cannot be static or init only" error
    It happens when I have "public readonly Arr<string> Prop" in my class. Without readonly works fine
    Jorge E. Alvarez
    @jealvarez
    Anybody can help me with the doubt that I posted yesterday? thanks in advance
    Nikita Ilyin
    @nike61
    @jealvarez there is ToEither I guess
    Jorge E. Alvarez
    @jealvarez
    with ToEither is mapped to Either<Exception, Option<Application>>
    and I would like to map it to Task<Either<IError, Application>>
    Nikita Ilyin
    @nike61
    @jealvarez
    var result = tryAsync .ToEither(x => "exception error description") .Map(x => x.Bind(o => o.ToEither("value is empty")));
    Instead of string you should use IError. Also try to use EitherAsync instead of Task<Either>
    Jorge E. Alvarez
    @jealvarez
    let me try it, thank you so much
    Nikita Ilyin
    @nike61
    Np
    Jorge E. Alvarez
    @jealvarez
    sorry for asked, what means .Bind()?
    I'm very new in c# and functional programming, so, it's difficult to understanding
    Nikita Ilyin
    @nike61
    it’s hard to explain in few words.
    Personally I recommend you
    1. https://www.manning.com/books/functional-programming-in-c-sharp
    2. Documentation of language-ext
    3. Scott Wlaschin on YouTube
    Jorge E. Alvarez
    @jealvarez
    sure!!! thank you!!!!
    Nikita Ilyin
    @nike61
    Np
    Nikita Ilyin
    @nike61
    @here hi everyone! any ideas about binary serialization of readonly Arr fields? I would be very grateful for help
    Joe Tremblay
    @jltrem
    Hi @louthy. Thank you for your detailed answer to issue #602. I've enjoyed using LanguageExt for two years now. Next week I'm doing a FP in C# talk for a local .NET User Group; some examples will use LanguageExt. Looking forward to contributing to the project!
    Paul Louth
    @louthy
    @jltrem Thanks Joe. That's great to hear, good luck with the talk!
    BrainCrumbz
    @BrainCrumbz
    Whoa! That post in issue #602 should go straight into some readme or docs, it is really something when read by people used by O.O.D.
    Joe Tremblay
    @jltrem
    following up on #602. @louthy's example subsystem has this log function:
            public static Subsystem<Unit> Log(string message) => () =>
                Out<Unit>.FromValue(unit, Seq1(message));
    I've added an additional one to simplify calling:
    public static MySubsystem<A> Log<A>(this MySubsystem<A> subsystem, Func<A, string> getMessage) =>
             from x in subsystem
             from _ in Log(getMessage(x))
             select x;
    Joe Tremblay
    @jltrem
    I've had trouble getting Log called when using LINQ fluent syntax. What would that look like?
    Paul Louth
    @louthy
    Sorry Joe, I don't follow, what's the trouble you're having?
    Joe Tremblay
    @jltrem
    just a few minutes -- let me work on a good example
    Joe Tremblay
    @jltrem
    var subsystem = Subsystem.Return(42);
    subsystem.Bind(val => Subsystem.Log($"number = {val}"));
    this works just fine. Geez. I'm not sure what I was doing yesterday when it "wasn't working" ... If I can recreate my problem then I may ping you again to see where I'm going wrong. Sorry for the bother. Thank you.
    Paul Louth
    @louthy
    No worries, glad it's working now :)
    Joe Tremblay
    @jltrem
    var result = Subsystem.Return(42);
    
    var test1 = result
       .Bind(val => Subsystem.Log($"number = {val}"))
       .Bind(val => result);
    
    var test2 = result
       .Map(val => Subsystem.Log($"number = {val}"))
       .Bind(val => result);
    ^ This is the problem I ran into: test1 contains the "number = 42" output but test2 does not. Both have the type Subsystem<int>. Bind+Bind vs Map+Bind is the only difference.
    Joe Tremblay
    @jltrem
    I see the problem in test2's val: the Bind is a Subsystem<Subsystem<Unit>>. I didn't explicitly use the value in the binding so the problem didn't jump out at me.
    Mike Hadlow
    @mikehadlow
    Hello Language-ext people. I'm looking at using this excellent library. Is there any advice anywhere for use with aysnc? So for example if I have a Task<Option<T>> type for example. I can see there are things like BindAsync, but also an OptionAsync type. What are the usage patterns for these?
    Mike Hadlow
    @mikehadlow
    Also: a straight clone->shift-F5 build from GitHub master results in errors with the LanguageExt.Tests project. Are there additional build steps that I need to do?
    BrainCrumbz
    @BrainCrumbz
    @mikehadlow we haven't tried building tests: have you tried starting from a known tag, instead of latest master? Re. async, the library provides a number of classes named SomeContainerAsync<> which can be interchanged with Task<SomeContainer<>>. So e.g. Task<Option<T>> can be replaced with OptionAsync<T>. Those XxxxAsync ones came later and we haven't worked with them, but they should actually just work in place of the formers
    Mike Hadlow
    @mikehadlow
    Thanks @BrainCrumbz
    Joe Tremblay
    @jltrem
    @mikehadlow the reference to the CodeGen project is wrong.
    change <ProjectReference Include="..\LanguageExt.CodeGen\LanguageExt.CodeGen.csproj" /> to <ProjectReference Include="..\LanguageExt.RoslynCodeGen\LanguageExt.CodeGen.csproj" />
    Paul Louth
    @louthy
    My bad, I’ll fix that up
    Paul Louth
    @louthy
    That's fixed now
    Greg Wintering
    @gwintering
    @mikehadlow - One of the best things about async in this library is you follow the same functional idioms as doing sync with the library and all the awaiting just happens without you having to drop into imperative mode. So Map, Bind, select, and Traverse like you would with sync types. You'll want to favor the library Async types instead of explicit Tasks because the HKT functions can only handle two levels of container nesting and the Async types hide the Task level; only use Task for interop outside the library. If you find yourself wanting to use Task.WhenAll to aggregate tasks, instead just throw the Async types into a collection(Seq, Lst, etc.) and .Sequence that collection.
    Stefan Bertels
    @StefanBertels
    Thanks for releasing 3.3.2, louthy.
    I stumbled upon strange errors after upgrading: Type initialization error when calling Option.Equals() by comparing Some("0") == "1" or Some("0)" == Some("1"). Replacing Some("0") with Some("") worked (?) and comparing to None, too.
    Solution was to upgrade all referenced packages to 3.3.2, too. Obviously using assemblies compiled again 3.1.24 does not work together with 3.3.2... No problem for me because packages were my own. This is just a note to other users.