← Back to context

Comment by lpil

1 month ago

It’s discouraged to pass around structs of functions to replicate type classes in Gleam. Instead the preference is to not type class style patterns in your projects, favouring a concrete style instead.

Does that mean pass every needed function as a parameter? Or just don’t write generic functionality?

  • Yes, one would use higher order functions, as is common in Erlang, Elixir, OCaml, Elm, etc.

    • At least half of those languages (Elixir and OCaml) have some sort of mechanism for ad hoc polymorphism (elixir has behaviors and protocols, OCaml has higher order modules) so I feel like the comparison doesn't work that well personally

      1 reply →