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

documentation for active patterns (`@active`) is out-of-date while deprecation warning is up-to-date

Open thautwarm opened this issue 2 years ago • 1 comments

https://github.com/thautwarm/MLStyle.jl/blob/2b7f0a7be19462ea741389266d5c3e04ead21409/src/StandardPatterns/Active.jl#L117-L147

thautwarm avatar Jul 30 '22 02:07 thautwarm

julia> @active F(x) begin
                if x > 0
                    nothing
                else
                    :ok
                end
            end

julia>

julia>  @match -1 begin
                F(:ok) => false
                _ => true
            end # true
ERROR: invalid use of active patterns: 1-ary view pattern(F(x)) should accept Union{Some{T}, Nothing} instead of Union{T, Nothing}! A simple solution is:
  (@active F(x) ex) =>
  (@active F(x) let r=ex; r === nothing? r : Some(r)) end

thautwarm avatar Jul 30 '22 02:07 thautwarm