News for hackers. Stuff that matters.
Re:Functional Programming in Elixir with Witchcraft by ed-209 on Wednesday February 09, 2022 @03:47AM (#30270436)
Never used Haskell but rather F#/OCaml and immediately fell in love with its maybe monads and partial function application. Couple years later I dipped my toes into Erlang and my initial disappointment with the absence of these constructs was replaced with intoxication upon my discovery of pattern matching. It is interesting to see this attempt at a best of both worlds but it only satisfies a curiousity at this point and not a need - everything just looks like pattern matching envy now.
Re:Functional Programming in Elixir with Witchcraft by ReleaseCandidat on Wednesday February 09, 2022 @04:19AM (#30270661)
> upon my discovery of pattern matching.

How is Erlang's pattern matching different from ML-like pattern matching? I only know Elixir, which is more or less the same as ML.

Re:Functional Programming in Elixir with Witchcraft by d3nj4l on Wednesday February 09, 2022 @10:16AM (#30273565)
Actually, I think Elixir's pattern matching is slightly worse than OCaml simply because there's no in-built syntax for multiple matches pointing to the same clause. Ex:

    (* In OCaml *)
    type t = A | B | C | D
    match A with
    | A | B -> "something"
    | C | D -> "else"
And in elixir:

    case :a do
      a when a in [:a, :b] -> "something"
      a when a in [:c, :d] -> "else"
    end
And of course, you lose exhaustiveness from type information, but that's a preference.

But, more to the point, I think what GP's referring to is partial function definitions via pattern matching on the arguments. That is intoxicating, and I wish OCaml had that.

Re:Functional Programming in Elixir with Witchcraft by ed-209 on Wednesday February 09, 2022 @01:01PM (#30275828)
Yes, matching structure of tuples in function definition etc.
Re:Functional Programming in Elixir with Witchcraft by ed-209 on Wednesday February 09, 2022 @01:00PM (#30275801)
No different.