[Haskell-cafe] Why purely in haskell?

David Roundy daveroundy at gmail.com
Thu Jan 10 10:59:40 EST 2008


On Jan 9, 2008 5:42 PM, Henning Thielemann
<lemming at henning-thielemann.de> wrote:
> > I just want to point out that unsafePerformIO is at the core of the
> > (safe) bytestring library.  As SPJ et al pointed out, this is crucial
> > functionality, and is only unsafe if unsafely used.
>
> Indeed, there are hacks and they are some times necessary. The good thing
> about Haskell is, that hacks look like hacks.
>
> In Modula-3 modules using hacks must be explicitly marked as UNSAFE. See
>   http://www.cs.purdue.edu/homes/hosking/m3/reference/unsafe.html
>  Maybe this is also an option for Haskell?

I don't think this is a good idea.  It comes down to a question of
whether you think it should be allowed for Haskell code to be used to
write core Haskell libraries in a first-class manner.  Perhaps you
think libraries should always be in C in order to avoid the use of
unsafePerformIO, but I prefer to allow them to be written in Haskell.

But then, I don't see unsafePerformIO as inherently a hack.  It's the
only possible way that certain useful abstractions can be
impelemented--at least, that's understanding.  I'd be curious as to
how much of the Prelude would be marked unsafe if you had your wish...

David


More information about the Haskell-Cafe mailing list