Live data from Hacker News

My Future with Elixir: set-theoretic types

elixir-lang.org

11–13 of 13 posts

Re: My Future with Elixir: set-theoretic types

#11

Earlier quoted context omitted.

Hi, author here. You do get a class of tests but I don't believe they are sufficient. For example, in the first article, we have this code: let contactFromEmail name emailStr = let emailOpt = EmailAddress.create emailStr // handle cases when email is valid or invalid match emailOpt with | Some email -> let emailContactInfo = {EmailAddress=email; IsEmailVerified=false} let contactInfo = EmailOnly emailContactInfo Some…

This code example doesn't make much sense. There is already a type to represent a valid email address (EmailAddress), why are we creating a function to make contacts that receives an email as a string. Just change the function to receive EmailAddress in the first place and avoid all the matching mess.

I agree,

You can /always/ go from `f : t -> r` to `f' : t option -> r option` with `Option.map` (ML-syntax, translate to w/e type syntax you're most familiar with), but the reverse is not true.

I think that the example is super-simplified though and I think that the central point still stands if you have multiple errors though.

Re: My Future with Elixir: set-theoretic types

#12
> "At this point in time, it seems the overall community would prefer a system that flags more potential bugs, even if it means more false positives."

I'm not sure this is true. While people who want static types are vocal about it , those who are happy with Elixir's current balance of dynamic typing with help from guards and pattern matching are generally quieter since they're well served by the language. At least of the Elixir devs I know, the overwhelming majority are not looking for a typed language. On the contrary, many of them moved to Elixir from Java or TypeScript because they didn't like the rigidity.

It's primarily people who haven't ever really used Elixir or Erlang for significant work that make the most noise about "needing" static types. There are some exceptions, but for the most part this is the dynamic I've seen.

Re: My Future with Elixir: set-theoretic types

#13
I write PHP and being able to give the arguments a type is such a nice thing, especially for self-documentation - hopefully this brings similar things to elixir, I really want to work with the language.

Besides that I wish for a really good LSP or other way to integrate to IDEs, especially to be able to jump to functions and see how they work exactly.

Post reply on HN