# Is there a result type library?

**URL:** <https://discourse.julialang.org/t/is-there-a-result-type-library/113224>\
**Category:** General Usage\
**Created:** [April 19, 2024, 8:29am UTC](https://discourse.julialang.org/t/is-there-a-result-type-library/113224 "2024-04-19T08:29:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![minetest2048](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/minetest2048/32/45961_2.png) [@minetest2048](https://discourse.julialang.org/u/minetest2048)\
**Post date:** [April 19, 2024, 8:29am UTC](https://discourse.julialang.org/t/is-there-a-result-type-library/113224/1 "2024-04-19T08:29:49Z")

</div>

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

```julia
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?

---

<div class="post-metadata">

**Author:** ![ShalokShalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shalokshalom/32/52462_2.png) [@ShalokShalom](https://discourse.julialang.org/u/ShalokShalom)\
**Post date:** [April 19, 2024, 9:11am UTC](https://discourse.julialang.org/t/is-there-a-result-type-library/113224/2 "2024-04-19T09:11:58Z")

</div>

> **[GitHub - JuliaFunctional/DataTypesBasic.jl: Option, Try, Either, and some...](https://github.com/JuliaFunctional/DataTypesBasic.jl)**
>
> Option, Try, Either, and some more common basic DataTypes - JuliaFunctional/DataTypesBasic.jl

> **[GitHub - hexane360/Results.jl: Result types and combinators in Julia](https://github.com/hexane360/Results.jl)**
>
> Result types and combinators in Julia. Contribute to hexane360/Results.jl development by creating an account on GitHub.

> **[GitHub - iamed2/ResultTypes.jl: A Result type for Julia—it's like Nullables...](https://github.com/iamed2/ResultTypes.jl)**
>
> A Result type for Julia—it's like Nullables for Exceptions - iamed2/ResultTypes.jl

---

<div class="post-metadata">

**Author:** ![jakobnissen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobnissen/32/13477_2.png) [@jakobnissen](https://discourse.julialang.org/u/jakobnissen)\
**Post date:** [April 19, 2024, 11:21am UTC](https://discourse.julialang.org/t/is-there-a-result-type-library/113224/3 "2024-04-19T11:21:02Z")

</div>

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.
