I’m working on an Elixir app at the moment and really enjoying it, but some of my recent dabbling in the type-safe worlds of Elm and Crystal have left me desiring a bit more structure in my code. The app I’m building involves a multi-step data transformation and so I have a data structure to properly represent this process. But since Elixir is a dynamically typed language, you can’t, for example, have a non-nillable field in a struct. The Elixir/Erlang ecosystem does, however, have a type-checking syntax called Type Specs, along with a tool, Dialyzer,...
Blog Entries tagged "elixir"
I’m in the middle of writing an application in Elixir and Phoenix, so when I saw a link to an article by José Valim on an upcoming authentication solution for Phoenix, my initial reaction (before reading it) was negative. José is the author of the Devise framework for Ruby-on-Rails, so I assumed it was going to be the same idea, but for Elixir and Phoenix. I’ve implemented Devise in a handful of Rails apps, and each and every time I ended up ripping it out and writing my own auth solution (often based on this Railscasts tutorial). The reason is that while...
When using Elixir, I’ve long missed the special
_ helper from irb that returns the result of the previous expression. Sometimes I actually type it out of pure habit.
Little did I know that Elixir has the same thing, except better.
IEx.Helpers has a function
v(n \\ -1) that returns the value of the nth expression in the session history. So
v alone returns the previous expression and
v(-2) returns the one before it.
iex(1)> "abc" iex(2)> "zyx" iex(3)> v "zyx" iex(4)> v(-3) "abc"
So instead I used VSCode’s support for Tasks to build the functionality myself. So in my project’s
tasks.json file, I have the following 3 tasks for running all tests, a single...
I’ve played around with VSCode here and there, but as a fairly picky Vim user who doesn’t do TypeScript, I never quite understood the hype.
Today I started up a new Elixir / Phoenix project (more on that to come) and tried out the Elixir Language Server Extension and the integration is very impression. Code completion, debugger support, automatic inference of Dialyzer Typespecs, documentation on hover, and more….
I don’t expect to be using VSCode as my standard editor (again, picky Vim user1), but I think I’ll stick with it on Elixir projects.