Facing a risk of being stomped all over again
        without reason, I nevertheless post this question
        to get to the bottom of things:

        When can I safely cheat haskell compiler/interpreter
        by pretending that I perform pure computations,
        when in fact they are not? Here is a real example,
        from my Md5Digest module which works fine in Hugs:

        digest :: String -> String
        digest string
            = unsafePerformIO (
                marshall_string_ string   >>= \x1 ->
                prim_Md5Digest_digest x1  >>= \x2 ->
                unmarshall_string_ x2     >>= \x3 ->
                return x3
              )


        From my naive perspective it should look to Hugs
        as a pure function - due to input argument.

        If this is correct then

        currentSecond dummyInput
            = cheat expression involving dummyInput and unsafePerformIO
 
        from my previous example should be, by extension, also
        safe to use. Correct? Or are there some lurking
        surprises that I am not aware of?

        Not that I like cheating though :-)

        Jan

 



Reply via email to