GithubHelp home page GithubHelp logo

Comments (4)

Munzey avatar Munzey commented on May 20, 2024 1

@mbucc just read this and your previous issue. I believe the exact thing you are looking for is called a monad comprehension.
I have opened a pr to add the functionality you are looking for:
#13

from kotlin-result.

michaelbull avatar michaelbull commented on May 20, 2024

I'm not familiar with F# so I don't really understand what's going on in the code linked

runCatching simply runs a bit of code, catching any exceptions and wrapping them in an Err to produce a Result<T, Exception>

from kotlin-result.

mbucc avatar mbucc commented on May 20, 2024

I'm back to my previous question on using unwrap. :)

I'm not an F# user either, but if I think I understand the explanation SW gives in his book, which is:

// A result computational expression:
result {
   // checkAddress returns a Result<Address, Msg>
   // but x1 is of type Address.
   let! x1 = checkAddress unvalidatedAddress
   let! x2 = checkName unvalidatedName
   return ValidatedAddress(x1, x2)
}   // Type of this full expression is Result<ValidatedAddress, Msg>

The closest match I can think of with kotlin-result is unwrap() on each line, all surrounded by runCatching. I know in a previous issue, you suggested not using unwrap() in this way, but I can't think of another way (other than continuing to expand zip).

from kotlin-result.

michaelbull avatar michaelbull commented on May 20, 2024

Maybe this comment helps?

from kotlin-result.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.