
On Fri, 2007-03-16 at 08:33 +0000, Simon Peyton-Jones wrote:
Can you give me a small program that demonstrates the issue? (With any support modules it needs, but the less the better.)
Ok, so the main thing to notice in this example is that the function that we keep in the Put (newtype) constructor is encapsulated in this module. The Put constructor is not exported and all the functions wrapped in Put are explicitly constructed in this module, we don't take in unknown functions from the outside. So it's an example where we could safely change the data representation with no external effect. http://haskell.org/~duncan/binary/ There's one module and a test module. There's also the stg output I get with ghc-6.6 -O There's only a half dozen functions, the three monad ops, and 'run', 'flush' and 'write'. Actually flush and run are not needed to compile the test example though at least run would be needed for anything to be useful. Then an actual instance of using 'write' is 'word8' which is very simple to define in terms of write. You'll notice in the source I ran into that issue I described the other day about write' being inlined despite the NOINLINE pragma. Duncan