[Haskell-cafe] Re: Functional version of this OO snippet
tom.davie at gmail.com
Fri Dec 5 12:50:54 EST 2008
On 5 Dec 2008, at 17:46, Duncan Coutts wrote:
> On Fri, 2008-12-05 at 17:06 +0100, Thomas Davie wrote:
>> On 5 Dec 2008, at 17:00, Duncan Coutts wrote:
>>> On Fri, 2008-12-05 at 16:50 +0100, Thomas Davie wrote:
>>>> Sure, and he could then use a fold instead of a map. Reading files
>>>> problematic, but as long as you're only doing it once (the most
>>>> situation) is entirely fine wrapped up in an unsafePerformIO.
>>> Please don't go telling people it's entirely fine to use
>>> like that (or at all really).
>> Exactly what isn't fine about it?
> It's the antithesis of pure functional programming. It's so unsafe
> we don't even have a semantics for it.
Yes, but we also don't have semantics for IO, so it's no real surprise
that we have none for something that runs an IO action.
> One needs pretty special justification for using unsafePerformIO and
> such cases should be hidden in libraries presenting pure interfaces,
> used willy-nilly in general application code.
> Note that I'm not claiming that it's necessarily going to do bad
> in the specific case you're imagining using it in. However just
> it happens not to do bad things in this case does not mean that it's
> to use it here or in general.
No, and I never said that it should be used more generally -- I was
very careful that in this case I was following the rules for making
sure that verifyItsSafeYourselfPerformIO was indeed safe.
More information about the Haskell-Cafe