The question mark infix used to be in the core library. It was removed for exactly the reasons described in the Design Guidelines. (I predict the exclamation point will meet the same fate.)
I personally have not found this infix useful because I am usually using Maybe.withDefault as part of a pipeline of operations. For example: operation |> anotherOperation |> Maybe.withDefault "default" |> letsDoSomethingElse On Mon, Jun 20, 2016 at 3:08 PM, Tim Stewart <[email protected]> wrote: > I just saw an example which used ? infix operator as a shorthand for > Maybe.withDefault: > > user.title ? "" > > Looking into it further I note that this is provided as the example of how > infix operators are defined in the Elm syntax guide: > > http://elm-lang.org/docs/syntax#infix-operators > > This seems like a great shorthand, very readable, reminiscent of related > concepts in other languages (null check operator in Groovy, optional types > in Swift). > > But then I read here and in the Design Guidelines that this is > discouraged, not idiomatic and just plain dumb. > > http://package.elm-lang.org/help/design-guidelines#avoid-infix-operators > > I'm interested in what others think about this specific use of infix. > > > On Monday, March 14, 2016 at 8:42:23 AM UTC+11, Max Goldstein wrote: >> >> Oh, I make the same error, really wish it was flatmap. But, I think >> andThen works better for things that aren't obviously data structures, like >> tasks and random value generation. The nice thing about not having type >> classes is that you don't have to make crazy compromises that work in all >> cases. For example, sometimes "singleton" is better, sometimes "constant" >> is better, and I personally will take the inconsistency over something >> uselessly vague like "return". >> > -- > 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.
