News for hackers. Stuff that matters.
Re:Gleam: a type safe language on the Erlang VM by vips7L on Wednesday November 08, 2023 @03:41PM (#38196635)
Isn't this solvable just by using types and instances rather than just calling top level/static functions? If you have a "replace" function off of String and use a Pattern type instead of a raw string, the compiler will enforce the correct type and ordering.

    val p = Pattern("https://[^/]*")
    val in = "https://google.com/some/path"
    val path = in.replace(p, "") // /some/path
In fact this specific example is solved just by having a dedicated type, for example URI:

    val path = URI("https://google/com/some/path").path; // /some/path

This feels like to me an answer in search of a problem.

There are no comments on this comment yet.