Git Product home page Git Product logo

Comments (6)

TheAngryByrd avatar TheAngryByrd commented on May 14, 2024

I think we would want to encode that into a new DU type with Ok | Warn | Error but that might be outside the scope of this library since we're only dealing with the FSharp.Core Result type. I know Chessie does it with Ok of 'a * 'Msg list | Error of 'Msg list but I don't really like how that's done.

from fstoolkit.errorhandling.

Swoorup avatar Swoorup commented on May 14, 2024

Would have thought Ok would contain ('value * 'warning list * 'info list) and Error just 'error list?

from fstoolkit.errorhandling.

TheAngryByrd avatar TheAngryByrd commented on May 14, 2024

You can do that but I don't like it since you're not using the type system to your advantage.

I'd say come up with a version that works and submit a PR so we can discuss the implementation if you find that pattern you've suggested useful.

from fstoolkit.errorhandling.

Swoorup avatar Swoorup commented on May 14, 2024

The reasoning for not choosing a DU is that, warnings/info are not necessary a failure or should cause the system to fail, only errors would. i.e I would want to be able to get the Ok value, and collect the warnings or infos and pipe it elsewhere like to logging or HTML views? Whereas error would cause a fail?

type Validation<'successValue, 'err, 'warn>  = 
	| Ok of 'successValue * 'warn list
    | Error of 'err

from fstoolkit.errorhandling.

AlexeyRaga avatar AlexeyRaga commented on May 14, 2024

I think that having warnings etc. should be somehow outside of the library concern. Like, what if I also want Info or Critical etc?.

One can always come up with their own way of tagging en error and just use it:

type Severity<'a> =
    | Critical of 'a
    | Warning of 'a
    
    
let (xxx : Validation<MySuccess, Severity<MyError>>) = ....

from fstoolkit.errorhandling.

TheAngryByrd avatar TheAngryByrd commented on May 14, 2024

Yeah since I haven't seen a PR for this and you could always build/layer your needs on top of this library I'm going to close this.

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.