Re: [Haskell-cafe] dangerous inlinePerformIO in Data.Binary(?)

2007-06-17 Thread Roberto Zunino
Udo Stenzel wrote: | toLazyByteString :: Builder - L.ByteString | toLazyByteString m = S.LPS $ inlinePerformIO $ do | buf - newBuffer defaultSize | return (runBuilder (m `append` flush) (const []) buf) Why is this safe? Considering the GHC implementation of IO, isn't there a real

Re: [Haskell-cafe] dangerous inlinePerformIO in Data.Binary(?)

2007-06-17 Thread Udo Stenzel
Roberto Zunino wrote: Floating out (newBuffer defaultSize) as in | foo = newBuffer defaultSize | | toLazyByteString m = S.LPS $ inlinePerformIO $ do | buf - foo | return (runBuilder (m `append` flush) (const []) buf) would still be safe, AFAICS. Floating out buf instead should

Re: [Haskell-cafe] dangerous inlinePerformIO in Data.Binary(?)

2007-06-15 Thread Duncan Coutts
On Thu, 2007-06-14 at 22:50 -0700, Stefan O'Rear wrote: | unsafeLiftIO :: (Buffer - IO Buffer) - Builder | unsafeLiftIO f = Builder $ \ k buf - inlinePerformIO $ do | buf' - f buf | return (k buf') which might be safe, since 'f buf' cannot float out of the lambda which

[Haskell-cafe] dangerous inlinePerformIO in Data.Binary(?)

2007-06-14 Thread Udo Stenzel
Greetings, I was trying to understand the magic inside Data.Binary, and found two somewhat suspicious uses of inlinePerformIO, which imho has a far too innocuous name: | toLazyByteString :: Builder - L.ByteString | toLazyByteString m = S.LPS $ inlinePerformIO $ do | buf - newBuffer

Re: [Haskell-cafe] dangerous inlinePerformIO in Data.Binary(?)

2007-06-14 Thread Duncan Coutts
On Fri, 2007-06-15 at 01:03 +0200, Udo Stenzel wrote: Greetings, I was trying to understand the magic inside Data.Binary, and found two somewhat suspicious uses of inlinePerformIO, which imho has a far too innocuous name: It's not really supposed to be a public api. We've decided to rename

Re: [Haskell-cafe] dangerous inlinePerformIO in Data.Binary(?)

2007-06-14 Thread Stefan O'Rear
On Fri, Jun 15, 2007 at 06:46:11AM +0100, Duncan Coutts wrote: On Fri, 2007-06-15 at 01:03 +0200, Udo Stenzel wrote: The other occurence is: | unsafeLiftIO :: (Buffer - IO Buffer) - Builder | unsafeLiftIO f = Builder $ \ k buf - inlinePerformIO $ do | buf' - f buf | return