
Quoting Sven Panne (2018-12-19 09:03:21)
I think Ian just wanted to demonstrate that it is possible to crash Haskell programs in the same way as C programs if you really want to. OTOH,
the name "unsafeCoerce" of the function used and its type (a -> b) alone should be very visible warning signs. ;-) Mere mortals should better forget about its existence,
..and this was more my point -- while it *is* possible to cause the same bad behavior in Haskell as in C, the language is constructed in such a way that it's hard to do so by accident.
Ian, by the way, how can you guarantee that Segmentation Fault will not happen in Haskell application?
You can't, and indeed it has happened in the past, sometimes due to compiler bugs, sometimes due to misuse of stuff like unsafeCoerce or the FFI. But it's literally never happened to me personally. My point is it's not about guarantees so much as whether getting things right is easy. Forgetting to check for NULL in C is a massive source of real-world bugs. Forgetting to check for Nothing in Haskell isn't. Note that the distinction *does* matter if you're thinking of building something like lambdabot, where you may be running malicious code. But for most purposes it doesn't.