Do not use Either. The Result type in the standard library is the same, but with the names more intuitive.
On Oct 7, 2016 11:58 PM, "Arthur Welf" <[email protected]> wrote: > If you want error messages, you can use type Either: > > type Either a b > = Left a > | Right b > > You define the set of values which are acceptable as arguments by your > function, and they will be executed in the Right branch. Every time your > function receives an unacceptable argument, it goes to the Left branch and > you can encode for it desired error message for that error. > > You can look at the realisation of the type and functions with this type > here: https://github.com/imeckler/either/blob/master/Either.elm > > 7 окт. 2016 г., в 4:48, Dave Ford <[email protected]> написал(а): > > Thanks Joey. > > >> you will handle the error case, and either come up with a sensible >> default, or tell your program to display some error message, or do >> something else to properly handle the error. >> > You mean, do exactly like I showed in the java newbie example? What would > be considered an anti-pattern in java? How is this a good thing? It seems > like a step backwards. > > Often there is no way to "handle" the error. There is no sensible default. > It's a programmer error and throwing an exception is the most logical thing > to do. > > Unless I am missing some key concept, this will make your programs less > reliable. True, there will be no runtime exception. But there will be bugs. > And more noise. > > Again, I will admit that I am new to Elm. And may be missing something. I > totally get the whole "maybe" thing. And I see the advantage of that. > > But, if I am not mistaken, we are back to C in the sense of "no throw"? > C#, Java, JavaScript, and Scala have the keyword throw. VisualBasic, > Python, Ruby, F# and Clojure have raise. > > Is there no throw/raise in Elm? We must use "return" for both standard > return and error return. Is that correct? > > I'm not trying to be a troll. There are lots of things I love about Elm. > I'm just trying to understand the language. Thanks. > > > > -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
