Metatheory.jl
Metatheory.jl copied to clipboard
Use Union{Some{T}, Nothing}
Currently rewriters don't distinguish between failing to match and successfully returning a value of nothing
.
I want to use this pattern:
y = r1(expr)::Union{Nothing, Some{Expr})
return isnothing(y) ? y : nothing : r2(something(y))
Rewriters could be Some
-aware and unwrap these values internally with something(x)
.
References
- A blog post about why this wrapping is good
- A similar issue for
Base.get
https://github.com/JuliaLang/julia/pull/34821 - A similar issue for
Base.maybetake!
https://github.com/JuliaLang/julia/pull/41966
cc @shashi