Avoiding CAF's

Simon Marlow simonmarhaskell at gmail.com
Thu May 24 07:30:35 EDT 2007

Neil Mitchell wrote:
> Hi Simon,
>> Ok, but suppose you get some good results - what's the point?  None of 
>> this is
>> guaranteed to work tomorrow.  Why not aim for a robust translation 
>> into Core
>> that preserves the semantics?  It can't be that hard to pass around a 
>> State#
>> RealWorld, can it?
> Is there a paper/document that gives the current design for the IO
> Monad as implemented in GHC, particularly with what things have zero
> runtime cost? I have a reasonable idea, but would like to make sure I
> know exactly whats going on before getting down to a very low level
> with this.

Not really, this is something we should document in the commentary.  The basic 
idea is that a value of type "State# s" for any s takes up zero registers or 
stack slots.  However, a value of type "State# s -> a" is certainly different 
from a value of type "a", because for example seq can tell the difference.  So 
an argument of type "State# s" behaves like any other argument: it can be 
partially applied, etc., the difference is that the actual value takes up no space.


More information about the Glasgow-haskell-users mailing list