News for hackers. Stuff that matters.
Re:Railway-Oriented Programming (2015) by amelius on Monday June 18, 2018 @08:37AM (#17337736)
So (+) would be defined as adding its operands, except if one of them is an error (in which case the result would be an error).
Re:Railway-Oriented Programming (2015) by jjaredsimpson on Monday June 18, 2018 @08:44AM (#17337762)
Either is a sum type. What if I don't want that. It's not about handling errors per se, but modeling the type.
Re:Railway-Oriented Programming (2015) by amelius on Monday June 18, 2018 @09:00AM (#17337862)
Yes, I understand. But by "implicitly" I really meant that. You don't see the type, only the compiler does. The programmer only sees the non-error part of the type (the "Right" part of Either).
Re:Railway-Oriented Programming (2015) by jjaredsimpson on Monday June 18, 2018 @01:50PM (#17340177)
How could this work? I specify an interface to an api.

C Foo(A a) = ...

Someone then provides me with some not-A error value. What should I do? What do you mean by implicit.

Re:Railway-Oriented Programming (2015) by KirinDave on Monday June 18, 2018 @01:30PM (#17340018)
> Either is a sum type. What if I don't want that.

Product types work as well, if you want. But unless your return type is a monoid (or like, a semilattice maybe?) then you're going to end up with Sum Types somewhere.

The vast, vast majority of software engineers and students work with sum types every day and they're totally fine with them. Most languages implicitly sum many values with null.