News for hackers. Stuff that matters.
Re:Functional Programming in Elixir with Witchcraft by Zababa on Wednesday February 09, 2022 @04:09AM (#30270592)
That was a nice article, however with a few caveats:

- I don't understand why you would use either, composed of left and right; where you could use result, composed of ok and err, which would be closer to regular Elixir.

- There's no mention of typechecking at all.

Re:Functional Programming in Elixir with Witchcraft by aroccoli on Wednesday February 09, 2022 @08:13AM (#30272221)
It's historically like that in Haskell, and that's how the library defines it. I agree that Result is much clearer, and would love to use it here. But then I would also have to go through how to use Algae to define the type instead of using it out of the box, which would make the article longer.

Similarly with typechecking -- Elixir is dynamically typed, not everyone uses dialyxir, and to bring that whole story inside would also complicate the article.

I plan to continue exploring this space, and perhaps I will slowly understand how to best introduce these ideas to Elixir people correctly, but right now I am just trying to approach it from different kinds of angles. Thank you for the comments. :)

-- Author

Re:Functional Programming in Elixir with Witchcraft by Zababa on Wednesday February 09, 2022 @08:52AM (#30272592)
Thanks for the explanations, that makes sense. It's a bit sad that Algae used the same convention as Haskell instead of going with something clearer.
Re:Functional Programming in Elixir with Witchcraft by ReleaseCandidat on Wednesday February 09, 2022 @04:23AM (#30270691)
> I don't understand why you would use either, composed of left and right;

Because Haskell uses `Either err a = Left err | Right a`

Re:Functional Programming in Elixir with Witchcraft by Zababa on Wednesday February 09, 2022 @06:32AM (#30271476)
That sounds like a situation where you copy what other people do without a good reason to do so.
Re:Functional Programming in Elixir with Witchcraft by ReleaseCandidat on Wednesday February 09, 2022 @07:52AM (#30272022)
Yes, exactly.