I usually use the ?~ method of the Box class in this manner:
myBox ?~ ("param %s is missing".format(param)). flatMap( ..... )
I use this a lot because it's an easy and concise way to add
meaningful error messages. But this means that String.format is being
evaluated every time, and in most cases this will not be necessary.
Wouldn't it be better is we would call the msg parameter in ?~ by
So instead of
def ?~(msg: String): Failure = Failure(msg, Empty, Empty)
def ?~(msg: => String): Failure = Failure(msg, Empty, Empty)
I'm not sure if there's a performance penalty in using named
parameters but the Loggable trait uses this for the same reason so I
immagine it's ignorable.