RE: help needed for adding isWHNF primop to 5.00.2

Hi all, Apologies for my large number of postings to this list of late.
the normal definition of WHNF applies only to types containing _|_, i.e. pointed types. Unpointed types are never represented by thunks, so I would be inclined to include them in WHNF.
Yes, I agree here. It is useful for me since I am using WHNF to determine whether expressions are evaluated. Perhaps it is a slight abuse of the terminology, but it gives me what I want :)
You also have to deal with indirections, although you can assume (at the moment) that an indirection will eventually lead to an object in WHNF.
Good point. I did make this assumption. Well to be precise I made the assumption that the thunk and indirection closure flags were mututally exclusive. If things change I guess I will have to follow the indirections. currently my definition is: #define isHNFzh(r,a) r=(! closure_THUNK((StgClosure *)a)) I believe under this definition that unpointed types and indirections are considered to be in WHNF. My initial tests seem to indicate that this is working well.
You have to declare the primitive like this, BTW:
isWHNF# :: a -> (# State# RealWorld, Int# #)
because the compiler doesn't know about the IO type and you can't return a Bool directly.
I'm not too fussed about the unboxed Int, although as Marcin points out it does look like some of the comparision primops can return a Bool. I couldn't figure out how they did it so I left it with the Int#.
There's no problem with the simplifier as long as you declare the primitive to have the correct properties, i.e. that the polymorphic argument is lazy.
Great.
It sounds like you also need a way to take apart arbitrary objects and look at their components.
Yes indeed. I use type classes for this with deriving rules for user defined types. I'm in the midst of writing this up for IFL, in Stockholm, mid September. In particular, I am looking for "portable" ways of taking objects apart, that's why type classes are attractive. Of course, isWHNF cannot be written in Haskell, but if I can get it to work for Hugs, GHC and NHC, then that is good enough for me :) What I hope is that some of this can appear as a Meta-programming library for Haskell, which is more powerful than Read and Show. Something a bit similar to the semantic domain of Meta-ML.
I know that Andy Gill was also interested in having similar facilities, perhaps he can help out.
I wonder if Andy is reading this? Possibly there are other people around who are also interested in this. I think the HAT people at NHC headquarters are also interested in these things. There once was talk of starting a debugging group for Haskell, but I don't know what happened. Thanks heaps for your help. Bernie.

I know that Andy Gill was also interested in having similar facilities, perhaps he can help out.
I wonder if Andy is reading this? Possibly there are other people around who are also interested in this. I think the HAT people at NHC headquarters are also interested in these things.
Certainly a couple of us at nhc HQ are listening in. In the old Hat system, we used an impure test for WHNF. In the new Hat, it is no longer needed. The reason we could abandon it is because we moved to a scheme for writing the trace to file, using a mechanism pretty similar to how HOOD does it. However, it is worth pointing out that this means we store trace information about (potentially) every reduction that ever happens - precisely what you are trying to avoid on grounds of cost. It must be admitted that Hat currently has a significant slowdown factor when running programs, but in user tests we have no complaints yet about speed. The value of keeping the complete trace information is that, once you have it, you can ask an enormous number of questions about it, getting answers rapidly without needing to recompile or rerun the program. In the trade-off between information-richness and speed, I think your average Haskell user trying to find a tricky program fault is really hungry for all the information they can get, and will be prepared to wait a little longer provided the info is good enough.
There once was talk of starting a debugging group for Haskell, but I don't know what happened.
The mailing list debuggers@haskell.org was set up and still exists, although I don't think it has ever had any traffic. I'd be pleased to see it being used. Regards, Malcolm

-----Original Message----- From: glasgow-haskell-users-admin@haskell.org [mailto:glasgow-haskell-users-admin@haskell.org]On Behalf Of Malcolm Wallace Sent: Tuesday, July 31, 2001 6:26 AM To: glasgow-haskell-users@haskell.org Subject: RE: help needed for adding isWHNF primop to 5.00.2
I know that Andy Gill was also interested in having similar facilities, perhaps he can help out.
I wonder if Andy is reading this? Possibly there are other people around who are also interested in this. I think the HAT people at NHC headquarters are also interested in these things.
What I want is gdb for GHC :-) Perhaps another build (like profiling vs optimizer), and when you press ^C, the ghcdb> prompt comes up :-) I did at one point want to look at providing a Java style reflection on polymorphic objects, towards having a non-evaluating print command at the gdbdb prompt. If anyone is interested in helping me flesh this out, then please email me. I wonder if the Cost Center Stack idea can be combined some debugging concepts, giving an approximation to a stack dump, and you can print (using a non evaluating print) the stack? Andy Gill

Andy writes:
What I want is gdb for GHC :-) Perhaps another build (like profiling vs optimizer), and when you press ^C, the ghcdb> prompt comes up :-)
Hey, we already have pretty-much exactly that in nhc98. :-)
I wonder if the Cost Center Stack idea can be combined some debugging concepts, giving an approximation to a stack dump, and you can print (using a non evaluating print) the stack?
Hey, we already have pretty-much exactly that in nhc98. :-) The new improved Hat now has several different debugging tools. hat-stack gives a stack dump hat-observe shows some or all actual uses of a function (cf. HOOD) hat-detect automated algorithmic debugging (cf. Freja) hat-trail the classic redex-trails browser (cf. "old" Hat) There are also "tunnels" between the latter three tools, so you can for instance jump from a dodgy observation straight into an algorithmic debugging session starting at the suspicious point. hat-observe is about the nearest thing to a gdb I can imagine in a lazy pure setting. For you ghc junkies out there, yes we are currently developing a compiler-independent version of Hat which should give you identical tracing facilities in ghc as in nhc98, at least for the Haskell'98 language. The port is very much in its early stages though, so if you want to try the Hat tools out and give us your feedback on whether they meet your needs, we would prefer that you don't wait for the compiler-portable version, but recommend using nhc98 for the moment. I expect to make a new release with some improvements to the tools within the next couple of weeks. Regards, Malcolm
participants (3)
-
Andy Gill
-
Bernard James POPE
-
Malcolm Wallace