Metatheory.jl icon indicating copy to clipboard operation
Metatheory.jl copied to clipboard

Use Union{Some{T}, Nothing}

Open adkabo opened this issue 2 years ago • 1 comments

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

adkabo avatar Jan 06 '22 21:01 adkabo

cc @shashi

0x0f0f0f avatar Jan 10 '22 11:01 0x0f0f0f