I am currently porting to Julia some Python code that contains a lot of pattern matching for decoding JSON messages received via network socket, which are represented conveniently in Python as dictionaries.
Since Julia doesn’t have pattern matching in Base, I have decided to use Moshi.jl, since it looks like the most recommended implementation. However, it seems that it doesn’t support Dict as a pattern. Minimal working example:
using Moshi.Match: @match
msg = Dict(
"error" => 2,
)
@match msg begin
Dict("error" => x) => x
_ => "unknown message"
end
The @match matches a wildcard pattern, i.e., returns string “unknown message”, but to my understanding it should match the Dict and return 2.
Am I doing something wrong here?