josevalim

josevalim

Creator of Elixir

Proposal: IEx hints

In Elixir we are continuously trying to improve the experience for developers learning the language. However, there are still common road blocks users run into, despite of the tips and warnings put into the learning materials.

This proposal is about a hints mechanism for IEx that will allow us to print some information and guidance to users in common situations.

As an example, imagine the situation where IEx prints a list as a char list for the first time, a situation newcomers often find themselves in:

iex(1)> Enum.map([0, 1, 2], & &1 + 10)
‘\n\v\f’

In such cases, we could print hints, such as (don’t worry about the hint content for now):

Did you expect a different result than '\n\v\f'?

By default Elixir prints a list of ascii characters in single quotes.
Since [10, 11, 12] is a list of characters, you saw the '\n\v\f' result
above.

Whenever you are in IEx and you are not sure about what a data type means,
use the `i/1` helper to give you more information:

    i('abc')

Each hint will be show only once. There will also be a function to disable all hints.

Before moving forward, the Elixir team has two questions:

  1. Would such hints be generally helpful?

  2. More importantly, which hints do you believe we could show on IEx? Hints should be valid language idioms that may be confusing when you first experience it. If an invalid construct is confusing, let’s say it has a poor error message, then we should improve the error message instead of adding a hint.

Please let us know when the hint should trigger and what we should suggest.

Thank you.

Note: This is an on-going discussion. Before joining the thread, please check the current discussion and see if your feedback and concerns haven’t already been brought up.

Most Liked

OvermindDL1

OvermindDL1

I’d personally think that would be greatly useful for new people yes.

OvermindDL1

OvermindDL1

Maybe instead of ‘default’ persistence it defaults to per-session, but at the bottom of each it says to run ‘some’ command to disable globally, which would add some kind of flag or so into the ~/.iex.exs or whatever file that disables globally.

I can very much see it being slightly irritating on new installs, but something like that would make it very easy to disable.

Neurofunk

Neurofunk

something great would be to be able to invoke a hint, independently of the context :slight_smile:

Last Post!

dwahyudi

dwahyudi

Rather than full text hints, could we create some knowledge base on the web?

So iex will just return the link to that knowledge base.

Enum.map([0, 1, 2], & &1 + 10)
'\n\v\f'

Hints: please visit https://elixir-lang.org/kb/45/ascii-char-in-single-quotes

With this kb, we can have better conversation when referring to hints.

“which hint are you talking about?”
“this one: https://elixir-lang.org/kb/110/genserver-call-and-cast

and if you want to update the hint, you could just update the kb on the web.

Where Next?

Popular in News Top

josevalim
Hello folks, There has been some doubts regarding StreamData and PropertyTesting in Elixir so we have decided to open up a thread to ans...
New
josevalim
NOTE: this is a focused thread, so we appreciate if everybody stayed on topic. Feel free to comment anything in regards to calendar forma...
New
Elixir
Release: Release v1.10.0 · elixir-lang/elixir · GitHub Support for Erlang/OTP 21+ Elixir v1.10 requires Erlang/OTP 21+, allowing Elixir ...
New
Elixir
Release: Release v1.10.4 · elixir-lang/elixir · GitHub 1. Bug fixes Elixir [Kernel] Fix a bug where custom types were printed as built-...
New
Elixir
Release: Release v1.13.0-rc.0 · elixir-lang/elixir · GitHub The focus behind Elixir v1.13 has been on tooling, mainly tooling related to...
New
Elixir
Code snippets in diagnostics Elixir v1.15 introduced a new compiler diagnostic format and the ability to print multiple error diagnostics...
New
Elixir
This release includes type inference of patterns to provide warnings for an initial set of constructs (binaries, maps, and atoms). It al...
New

Other popular topics Top

jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement