Skip to content

Instantly share code, notes, and snippets.

View the-mikedavis's full-sized avatar

Michael Davis the-mikedavis

View GitHub Profile

Nominal types are new in Erlang/OTP 28: https://www.erlang.org/eeps/eep-0069

Previously the dialyzer considered two types to be the same only if they were structurally equal. For example {number(), number()} created in one place is equivalent to any other {number(), number()} with structural typing. With nominal typing two types are considered the same only if their type has the same name. In Erlang this means that you have functions with specs that say they return a type defined with -nominal Type :: Definition..

Nominal types have slightly worse ergonomics since you need to have APIs for producing and modifying the type. For example even though nom_index is a non_neg_integer(), we can't say Index + 1 in nom.erl. Instead we would need a function nom_index:next/1 which returns a nom_index:t().

Nominal typing is very powerful, however, and a really great addition to the Erlang type system, because the dialyzer can now distinguish between two types which are structurally equivalent bu

@the-mikedavis
the-mikedavis / jaro.erl
Last active January 6, 2025 22:32
-module(jaro).
-export([distance/2]).
%% This is an Erlang translation of Elixir's `String.jaro_distance/2'.
%% Upstream: https://github.com/elixir-lang/elixir/blob/v1.15.7/lib/elixir/lib/string.ex#L2784-L2879.
%% Jaro Distance is relatively simple - only transpositions of grapheme
%% clusters are allowed which is much simpler than other edit distance
%% measurements like Damerau–Levenshtein (insertion, deletion, substitution
@the-mikedavis
the-mikedavis / BUILD
Created January 19, 2023 16:14
Bazel resize exit MWE
load("//:defs.bzl", "build_run", "build_test")
build_run(name = "hello-run")
build_test(name = "hello-test")
@the-mikedavis
the-mikedavis / erlang.kak
Last active January 6, 2025 22:31 — forked from subsetpark/erlang.kak
A half-baked kakoune language file for erlang.
# Detection
# ---------
hook global BufCreate .*[.](erl|hrl|app\.src) %{
set-option buffer filetype erlang
}
hook global BufCreate .*/rebar.config %{
set-option buffer filetype erlang
}