4 ms·
So, Either String a <=> Maybe a, but with a nice reason something went wrong.
by Tyr42 14y ago
So, Either String a <=> Maybe a, but with a nice reason something went wrong.
- mercurial 14y agoNot quite. They are not restricted to error handling. You can have methods returning a Maybe something without it being an error (just like there are plenty of valid reasons for returning null instead of throwing an exception). You can also use Maybe in a data structure: data Employee = Employee { name : Text, spouse : Maybe Text } You may also want to use Either to store two possible outcomes of an operation, though I would recommend using your own sum type for clarity: data MyOwnEither a b = MyLeft a | MyRight b