| > | Also, is there a way to do something similar but for 'lazy' rather than
| > | 'seq'? I want something of type
| > |
| > | type World__ = State# RealWorld
| > |
| > | {-# NOINLINE newWorld__ #-}
| > | newWorld__ :: a -> World__
| > | newWorld__ x = realWord#  -- ???
| > |
| > | except that I need newWorld__ to be lazy in its first argument. I need
| > | to convince the opimizer that the World__ newWorld__ is returning
| > | depends on the argument passed to newWorld__.
| >
| > I don't understand what you meant here.  The definition of newWorld__ that 
you give is, of course,
| lazy in x.
|
| it is getting type 'Absent' assigned to it by the demand analysis, I
| want it to be lazy (and not strict)

Ah I think I understand now.  You want a lazy primop
        discard# :: a -> ()
Now you can write
        newWorld x = discard x `seq` realWorld#

The code generator treats (discard# x) as (), and
(case (discard# x) of () -> e) as e.

It should be a primop so that this behaviour is not exposed too early.  An 
alternative would be to do the transformation in the core-to-STG step, but that 
might be too early.   Still easier would be to write
        discard x = ()
        {-# NOINLINE[0] discard #-}
to prevent it getting inlined until the final stages of the optmisier.  The 
trouble is that I have no idea of what it means to expose discard "too early" 
is in your case.

Not hard to implement if you feel like doing so.

Simon
_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to