bharendt / May 28 2018
Elixir
Elixir
elixir
Download as Docker image from:
This image was imported from: elixir
bash_path="$(which bash)" cp "$bash_path" /usr/local/bin/real-bash echo "#!/usr/local/bin/real-bash" > "$bash_path" echo "shift; shift; shift" >> "$bash_path" echo "$(which elixir) -e \"\$@\" " >> "$bash_path"
Replacing the bash binary with the elixir binary, a common bash cell can be used as elixir interpreter:
IO.puts "hello elixir"
Replacing a python next-repl interpreter with an elixir repl, which loads the repl code from a (transcluded) cell, we can upgrade an elixir interpreter to a next repl, opening a port on 9999 and reading code from it and responding with transit events.
python_path="$(which python)" echo "#!/usr/bin/env bash" > "$python_path" echo "$(which elixir) -e \"\$(cat <<EOS $(cat <<EOM EOS EOM ) )\"" >> "$python_path" cat $python_path
This is the basic nextrepl code:
{:ok, socket} = :gen_tcp.listen(_port = 9999, [:binary, active: false, reuseaddr: true, ip: {0,0,0,0}]) {:ok, client} = :gen_tcp.accept(socket) tag_write = fn(tag, data) -> line = "[\"~:#{tag}\",{}]" :gen_tcp.send(client, line) end tag_write.('nextrepl/hello', {}) tag_write.('prompt', {}) loop = fn(loop) -> {:ok, data} = :gen_tcp.recv(client, 0) IO.puts "received " IO.puts inspect(data) loop.(loop) end loop.(loop)
This would be a stateful elixir repl. It does not finish booting yet,
1
because the eval step is missing, but that would be only some few more lines...
# eval code (to be done)