Stop aliasing String.t and integer

I’m learning Elixir and, a little unwillingly, learning about it’s system of type specifications. I will concede that being able to specify the types of return values is helpful but I am not sure about the rest. Nevertheless I am told the Dialyzer system (that analyses type information and looks for errors) can be very helpful so for now I am playing along.

While reading the documentation something caught my eye:

Defining custom types can help communicate the intention of your code and increase its readability.

defmodule Person do
   @typedoc """
   A 4 digit year, e.g. 1984
   @type year :: integer

   @spec current_age(year) :: integer
   def current_age(year_of_birth), do: # implementation

I found myself puzzled by this statement. The argument in question year_of_birth is already clearly indicating it’s a year. And the type cannot enforce the rule “A 4 digit year, e.g. 1984”.

So what is the type spec adding? It seems to me that what it’s adding is a step of cognitive overhead in understanding that what is being passed is an integer.

I’ve seen other examples of creating types for username and password that alias the String.t type and again I find this unconvincing since the function being spec’d almost certainly calls it’s arguments username and password so what is being added?

Where a type adds useful information I buy it. A struct for example is already a kind of alias since it defines compound structure. But for primitive types like String.t and integer it seems like adding aliases is hiding information not adding to it.

My problem with browsers

In this post I am going to outline the challenge that I face in using browser to do my work. In a future post I will draw together some ideas about what I can do about it.

I am one of those people who routinely has 200 or more open tabs in my browser, spread across several windows. I realise I am a degenerate case but there we are, I don’t seem likely to change.

But browsers like Chrome, Safari, and Brave even though they are mostly capable of handling this aren’t designed for you to work with hundreds of tabs. You end up with things like this. Not, I would argue, very useful.

Tabs don’t work past a certain limit.

Then again bookmarks, either in the browser or using services like, are not a very effective approach to dealing with the problem. I can use them to “hide” tabs … but I find that I either forget about them entirely and lose track of what I was looking in to, or I feel uncomfortable because something is hidden from me. History isn’t a great tool here either; it’s like bookmarks but worse, especially since Chrome only holds on to history for 3 months!

The problem is one of doing research, across a range of threads, and multiple open loops.

For example, I am:

  • Researching business models for a guide I am writing for work (2 weeks+)
  • Exploring a range of topics related to the Elixir programming language, Ecto database layer, and Phoenix web stack (3 months+)
  • Carrying on a long-term research project about business strategy (2 years+)
  • Keeping up on current news (day-to-day)
  • Looking into how to do customer success in a SaaS context (4 weeks+)
  • Researching and building parser combinators (2 months+)
  • Sketching the outline and business model of a new application (5 months+)
  • Working on a pitch deck (3 months+)
  • Looking at some Minecraft resources (12 months+)
  • Exploring pricing & pricing support services (6 months+)
  • Learning Postgresql (2 weeks+)
  • Exploring how teams think about strategy together (6 months+)

I mean there are more threads than this, but I’d have to spelunk a lot more tabs to cover it fully. Some of my tabs will be over a year old (about when Chrome last lost everything). A tab in this context represents the current, dangling, end of a train of thought.

Some of these trains of thought have been going on for years. Browser sessions are pretty ephemeral and they don’t very well respect my approach. Sometimes the browser dies and takes a hundred or more tabs with it. Sometimes I get them back, sometimes I don’t. Sometimes I end up with a duplicate window and have to weed.

You could say “don’t do this” and maybe you’d be right for you but this is how I am. I’m not going to fight it. That means I need to find a way to adapt the tools to work better for me.

See also: Browser tabs are probably the wrong metaphor