4 ms·
I read that as "it amazes me that people aren't all using Haskell yet". Because 'show' is probably all done for side effects. And then, maybe, Haskell would ha
by outworlder 11y ago
I read that as "it amazes me that people aren't all using Haskell yet".
Because 'show' is probably all done for side effects. And then, maybe, Haskell would have caught that, due to the wrong type signature. If called from an otherwise pure function.
Most other "strong typed" languages wouldn't catch that. But that's hardly something type systems solve on their own.
- zeckalpha 11y agoEven Java would have caught that assuming .show() is Java's .toString().
- mcherm 11y agoNope. Creating a Toast object just creates the object. Calling .show() on the newly created object is what makes it actually draw something on the screen. The difficulty here is to realize that "new Toast(myMessage)" is not enough, you need to execute "new Toast(myMessage).show()". By the way, I am 100% sure that Java wouldn't have caught that, because this IS Java.
- e12e 11y agoI'm not sure how one would encode that information in java. Isn't toString() a special case in java? If you try to cast any object to a String, something (String?) will look for the toString class. I'm not sure what the equivalent would be for a widget that can be perfectly valid to add to another widget both in a hidden, and show()n state? To compare with toString, it's more like if you didn't do obj.show(), obj.toString() would return the empty string?