Re:Things I Was Wrong About: Types
by eru on Sunday September 27, 2020 @10:14AM
(#24606759)
Sum types even work when you actually have the multiple of the same return types. (Ie in Haskell `Either String String` works just as well as `Either String Int`; the types don't have to be distinctive.)
[ Parent
| on HN ]
Re:Things I Was Wrong About: Types
by a1369209993 on Sunday September 27, 2020 @07:48PM
(#24611235)
Also, `Maybe (Maybe a)` works correctly, contra possibly-null values in dynamically-typed languages. It's a surprisingly significant issue given how seemingly trivial it can sound.
That follows from the definition being tagged 'Left'/'Right':
Either a b = Left a | Right b