Erlang
iex
I learned that iex isn't technically a true REPL 5.
elixir
Application logging
I also got to take a deeper foray into application logging. I've been working on a more complex feature for work and would like to be able to track down any causes of bugs so IO.inspect
and the like aren't going to be enough.
It turns out that logging in elixir is actually quite simple. As expected it follows industry practices of having different level support. Check out more at [6],[7].
The latest release of Elixir
A new release of elixir is in release candidate.
https://github.com/elixir-lang/elixir/releases/tag/v1.10.0-rc.0
Writing documentation
https://hexdocs.pm/elixir/writing-documentation.html
Guards
Calling into functions that can throw
Ran into this
== Compilation error in file lib/vs_integrations/petco/pgr/pet.ex ==
** (CompileError) lib/vs_integrations/petco/pgr/pet.ex:11: cannot invoke remote function patient.client/0 inside guards
(stdlib) lists.erl:1354: :lists.mapfoldl/3
Associated code
def map_patient_to_pet(patient) when
patient.client != nil
do
...
You can write your own guards
https://hexdocs.pm/elixir/guards.html
mix tasks
https://elixirschool.com/en/lessons/basics/mix-tasks/#custom-mix-task
Environment variables
https://elixirforum.com/t/how-to-use-if-or-other-condition-for-dev-or-prod/16235
https://hexdocs.pm/elixir/master/Config.html
Discovering nodes
http://elixir-recipes.github.io/concurrency/connecting-nodes-same-machine/
Ecto
Joining multiple tables
https://elixirforum.com/t/ecto-how-to-join-three-tables/14485
Scripting
https://thoughtbot.com/blog/is-elixir-a-scripting-language
Real world reference projects
https://github.com/thechangelog/changelog.com/tree/master/lib
exunit
Running a single test in exunit
It's possible to run a single test in exunit.
mix test /tests/path/to/test/some_test.ex:123
tags
You can create tags for unit tests.
Exmachina
Connection ownership
To spawn or not to spawn
https://www.theerlangelist.com/article/spawn_or_not
Blogs
- My bad ideas: A blog about erlang and functional programming
- Keathley