Skip to content

Instantly share code, notes, and snippets.

View lagebr's full-sized avatar

Henrik Lagebrand lagebr

View GitHub Profile
@lagebr
lagebr / sumtype.java
Last active January 12, 2025 19:43
Example of sum type in java, using records.
import java.util.List;
class SumType {
public static void main(String[] args) {
Status p = new Pending("outstanding");
Status c = new Completed("123");
Status e = new Errored("io_exception");
List.of(p, c, e)
.stream()
.peek(a -> {
-module(test).
-include_lib("eunit/include/eunit.hrl").
succeed_test() ->
ct:print("Hi"),
io:format(user, "Hi", []),
ok.
@lagebr
lagebr / ets_counter_example_single.erl
Last active August 23, 2020 09:08
Single counter example using ets:update_counter
T = ets:new(t, [set]).
ets:insert(T, {c, 0}),
ets:update_counter(T, c, [{2,1}]),
ets:lookup(T, c).