Gleam v2 rewritten to use closures and functions instead of objects