Is there a result type library?

I really missed my Result type from Rust, so I’ve keep writing this on my libraries using SumTypes.jl:

using SumTypes

@sum_type Result{A, B} begin
    Ok{A}(::A)
    Err{B}(::B)
end

#Some functions to work with result types from Rust
unwrap(a::Result) = ...

Does anyone else does this, and if yes, do you make your own result type or you use a library?

2 Likes

I created ErrorTypes.jl specifically to mirror Result and Option from Rust. You might want to check that out.

Though I must say, I’ve stopped using it myself. In my opinion, the regular Union types are overall preferable to result types in Julia, although there are certainly advantages to either approach.

3 Likes