You need to use string macros here or a special repl mode if you want this syntax.
using ReplMaker
using REPL: LineEdit
iscomplete(x) = true
function iscomplete(ex::Expr)
if ex.head == :incomplete
false
else
true
end
end
function valid_code(s)
input = String(take!(copy(LineEdit.buffer(s))))
iscomplete(parse_forall(input))
end
function parse_forall(s::String)
Meta.parse(replace(s, "∀" => "for"))
end
julia> initrepl(parse_forall,
prompt_text="∀ julia> ",
prompt_color = :blue,
start_key=')',
mode_name="∀_mode",
valid_input_checker=valid_code)
REPL mode ∀_mode initialized. Press ) to enter and backspace to exit.
∀ julia> [x^2 + 1 ∀ x ∈ -3:3]
7-element Array{Int64,1}:
10
5
2
1
2
5
10
∀ julia> ∀ x ∈ 1:4
@show x + 1
end
x + 1 = 2
x + 1 = 3
x + 1 = 4
x + 1 = 5