by denvaar · 3y ago · 0 comments
Totally agree with this. I prefer to not use aliases most of the time, or to explicitly list out each module path separately if they are too long to fit inline. All preferences though.
> Similarly, I don’t like comprehensions as everything they do can be achieved with functions, and they are not composable.
I don't use comprehensions too often, but I would miss them if they vanished. Some things are just plain easier with them. They are also valuable in unit tests to show better error messages[1]:
# Don't do... assert Enum.all?(posts, fn post -> %Post{} == post end)
# Do... for post <- posts, do: assert %Post{} == post
EDIT: Although I suppose you could just use Enum.each as well.
But that's really nitpicking.
Remembering the difference between require, use and import, now that is a struggle.
Something to do with require being a macro and being lexically scoped (but you could probably just require it in the usings for Phoenix right?)
> Totally agree with this. I prefer to not use aliases most of the time, or to explicitly list out each module path separately if they are too long to fit inline. All preferences though.
recode[0] has a formatter plugin that reformats grouped alias/import/requires