[Haskell-cafe] Haskell Propeganda

David Roundy daveroundy at gmail.com
Tue Aug 26 09:54:19 EDT 2008

On Sat, Aug 23, 2008 at 6:15 PM, Daniel Fischer
<daniel.is.fischer at web.de> wrote:
> Am Samstag, 23. August 2008 23:17 schrieb Thomas Davie:
>> I'd be interested to see your other examples -- because that error is
>> not happening in Haskell!  You can't argue that Haskell doesn't give
>> you no segfaults, because you can embed a C segfault within Haskell.
> Use ST(U)Arrays, and use unsafeWrite because you do the indexchecking
> yourself. Then be stupid and confuse two bounds so that you actually write
> beyond the array bounds.
> I've had that happen _once_.
> But if you explicitly say you want it unsafe, you're prepared for it :)

Which illustrates the point that it's not type safety that protects us
from segfaults, so much as bounds checking, and that's got a
non-trivial runtime cost.  At least, most segfaults that *I've* caused
(in C or C++) have been from overwriting the bounds of arrays, and
that's precisely the problem that Haskell does *not* solve using its
type system.  There have attempts to do so, but I've not heard of
instances where they have been used in real programs.


More information about the Haskell-Cafe mailing list