Skip to content

Refactor Mix.Gleam#1

Open
eksperimental wants to merge 1 commit intoPapipo:add-gleam-compilerfrom
eksperimental-forks:Papipo/add-gleam-compiler+
Open

Refactor Mix.Gleam#1
eksperimental wants to merge 1 commit intoPapipo:add-gleam-compilerfrom
eksperimental-forks:Papipo/add-gleam-compiler+

Conversation

@eksperimental
Copy link

@eksperimental eksperimental commented Feb 27, 2026

  • Renamed Mix.Gleam.require!/0 to Mix.Gleam.requirements!/0 as it has a different meaning in Elixir.

  • Added/ @spec annotations to public functions.

  • Avoided making functions raise and return results ({:ok, value} | {:error, message})

  • Now every function that raises ends with a ! (with the exception of Mix.Gleam.load_config/1 due to consistency with the Rebar compiler)

  • Avoided raising from Elixir functions, and raise with Mix.raise/1 almost exclusively, raising with a descriptive message as opposed to raising with a generic message and a stacktrace. The exceptions are the use of JSON.decode!/1 since there's no way to translate the error atoms to string messages, as well as File.cd!/2.

  • Simplify the calls to Mix.raise/1 with the introduction of a helper. Now only 3 times the helper is called to return the value in the {:ok, value} tuple, or to Mix.raise with a message.

  • Mix.Gleam.parse_dep!/2 now users pattern matching to build its specs.

  • Renamed @required_gleam_version to @gleam_version_requirement for clarity.

  • Mix.Gleam.requirements!/0 raises with a descriptive message saying the minimum gleam version isn't met, as opposed to before where if this requirement is not met it wouldn't even raise

- Renamed `Mix.Gleam.require!/0` to `Mix.Gleam.requirements!/0` as it has a
  different meaning in Elixir.

- Added/ `@spec` annotations to public functions.

- Avoided making functions raise and return results (`{:ok, value}` |
  `{:error, message}`)

- Now every function that raises ends with a ! (with the exception of
 `Mix.Gleam.load_config/1` due to consistency with the Rebar compiler)

- Avoided raising from Elixir functions, and raise with `Mix.raise/1` almost
  exclusively, raising with a descriptive message as opposed to raising with a
  generic message and a stacktrace. The exceptions are the use of
  `JSON.decode!/1` since there's no way to translate the error atoms to string
  messages, as well as `File.cd!/2`.

- Simplify the calls to `Mix.raise/1` with the introduction oof a helper.
  Now only 3 times the helper is called to return the value in the
  `{:ok, value}` tuple, or to `Mix.raise` with a message.

- `Mix.Gleam.parse_dep!/2` now users pattern matching to build its specs.

- Renamed `@required_gleam_version` to `@gleam_version_requirement` for clarity.

- `Mix.Gleam.requirements!/0` raises with a descriptive message saying the
  minimum gleam version isn't met, as opposed to before where if this
  requirement is not met it wouldn't even raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant