Git Product home page Git Product logo

Comments (3)

cmeeren avatar cmeeren commented on May 14, 2024

It's not possible to have SRTP with module functions. But I don't see why you would need that, because there's no SRTP involved in the current definition of the operators (they simply alias Result.bind etc.). So AFAIK your example should work correctly already (apart from the fact that you're calling the tryCreate functions with two parameters when your definition of them only accepts one parameter).

In other words: The right-hand side of the operator is a simple Result<_,_> value, not a type with a tryCreate function. The fact that the documentation currently uses static members called TryCreate is purely coincidental; it could just as well use functions such as you describe.

(Do let me know if I'm wrong; I don't have full knowledge of this library, but this fits with what I can observe.)

from fstoolkit.errorhandling.

AlbertoDePena avatar AlbertoDePena commented on May 14, 2024

@cmeeren I see your point, after looking into it a bit more, I noticed that I am not bound to using member TryCreate There are other ways to accomplish the same thing =)

Thanks for quick response =)

from fstoolkit.errorhandling.

demystifyfp avatar demystifyfp commented on May 14, 2024

Thanks, @cmeeren for jumping in.

@AlbertoDePena, The rationale behind the current implementation is based on this example https://demystifyfp.gitbook.io/fstoolkit-errorhandling/index/trycreate#example-1 in the documentation.

The overall idea was inspired by clojure.spec where each attribute type will have its own validation logic in the form a static member TryCreate and then compose these attributes to form different entities. By using the Result.tryCreate, we can leverage this individual attribute level validation across any entities.

from fstoolkit.errorhandling.

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.