bang patterns give fundamentally new capabilities?

Kirsten Chevalier catamorphism at gmail.com
Mon Dec 4 10:15:10 EST 2006


On 12/3/06, John Meacham <john at repetae.net> wrote:
> On Sat, Dec 02, 2006 at 11:02:28PM +0000, Simon Peyton-Jones wrote:
[snip]
> > | 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)
>
> 3 newWorld__ :: a -> World__ {- Arity: 1 HasNoCafRefs Strictness: A -}
>

Well, yeah, that's because it *is* absent. If you want to convince the
demand analyzer that it isn't, then use x somewhere on the right-hand
side of the definition of newWorld__. Maybe I could be more helpful if
I knew what you were really trying to do here? (My best guess is that
you're trying to implement your own IO monad, which really shouldn't
be possible AFAIK unless there's something seriously wrong with GHC
that I don't know about. Unless you use The Function That Shall Not Be
Named.)

Cheers,
Kirsten

-- 
Kirsten Chevalier* chevalier at alum.wellesley.edu *Often in error, never in doubt


More information about the Glasgow-haskell-users mailing list