Rich_Morin

Rich_Morin

Elixir could suggest functions in other modules

When Elixir doesn’t recognize a variable name, it tries to make helpful suggestions. It could also make suggestions when a program tries to use a function that isn’t available.

For example, when the user tries to run List.join/2, Elixir could suggest Enum.join/2. (I’d submit this as an Issue on GitHub, but I don’t know where it should go. :-})

-r

Most Liked

LostKobrakai

LostKobrakai

That’s the type of suggestion it will probably never be able to give. The existing suggestions just iterate through all variables or all function names and compare what you wrote in your code with what’s available. So it’s a simple similarity check of strings.

Knowing that List.join should be Enum.join on the other hand requires a whole lot of extra knowledge about elixir – even knowing that List might correspond to Enum in the first place. As most Enum functions return lists it does fit quite well as suggestion for List, but what about other modules of enumerable types like Map or Tuple. For Map.map/2 I’d expect different behaviour as Enum.map, as it should return a map not a list. The proper suggestion would imho rather be Map,new/2, which takes an enumerable (so also a map), maps over it and returns a map. Or e.g. Tuple.filter/2: Even though there’s a Enum function of that name filterering doesn’t make very much sense for tuples, which are meant to be fixed-size containers of data. Even List.group_by doesn’t fit Enum.group_by very well, as it’s one of the few Enum functions not to return a list, but a map of data.

Where Next?

Popular in Discussions Top

CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
pdgonzalez872
If this has been asked here before, please point me to where it was asked as I didn’t find it when I searched the forum. Maybe a mailing ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 14350 124
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement