RE: help needed for adding isWHNF primop to 5.00.2
| I would like to add a primitive to GHC 5.00.2 of the form: | | isWHNF :: a - Bool One might be inclined to ask what for? Such a primitive is probably difficult to implement, given the variety of GHC's closures, and is potentially dangerous -- you could conceivably break referential transparency (?) I can also imagine it could interact badly with the complexities of GHC's simplifer. What would you hope to gain from such a thing? Perhaps you have some wider purpose which could be achieved some other way? J ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: outputs during runtime
Nicole Gabler [EMAIL PROTECTED] wrote: During runtime I want the program to output = information about the status every time another file is parsed. That = doesn't work, the output appears much later, mostly not until end of = program. But I need these outputs at that specific time, so what can I = do to manage it? Perhaps the following fragment from my prelude extensions helps. It requires ``import IO''. Most probably you would either be calling printList \n statusInformationList or factor out the flushing part for interleaving with your other IO actions. Wolfram %{{{ hPutList, printList It is frequently annoying if a long-running program writes a list of items to a channel or file, and while it calculates the next item, the last item has usually not yet been (completely) written because at least part of it is still held in some output buffer. The following functions flush the output buffer after every item. The most general variant, \verb|hPutList|, is parameterised by a separator string for list items, a \verb|shows| function for items, and a handle for output. The variant \verb|putList| writes always to the standard output channel, and \verb|printList| in addition uses the \verb|shows| function supplied by the type class system. \begin{code} hPutList :: String - (a - ShowS) - Handle - [a] - IO () hPutList sep shows h = mapM_ f where f x = hPutStr h (shows x sep) hFlush h putList :: String - (a - ShowS) - [a] - IO () putList sep shows = hPutList sep shows stdout printList :: Show a = String - [a] - IO () printList sep = putList sep shows \end{code} %}}} ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: linking with c++ libraries
| To reliably link with C++, you need to compile both the code | which invokes C++ (i.e. whatever uses the C++ library) and | main (that is, ghc/rts/Main.c, not main.hs) with a C++ compiler. | | So, in summary: | | - Compile any code which may call the C++ library (and keep | inter-module inlining in mind; probably safest to compile | all of your code this way) via C, and compile the C with g++. | | - Re-compile the run-time system (at least Main.c) with | g++, too. | | That may not fix your specific core dump, but you'll need to | do this anyway. After some discussion in the GHC office, we're unsure about why you need to compile Main.c with a C++ compiler for this to work. Pls can you clarify? J ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: linking with c++ libraries
G'day all. On Mon, Jul 30, 2001 at 06:06:07AM -0700, Julian Seward (Intl Vendor) wrote: After some discussion in the GHC office, we're unsure about why you need to compile Main.c with a C++ compiler for this to work. Under g++ you may not strictly need it. I'm not sure about that. However, some C++ systems do. Such systems handle static constructors and destructors by rewriting the main() function to perform the initialisation and destruction. See also Eric Myers, More Effective C++ item 34. It's also touched on briefly in the C++ FAQ: http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html Cheers, Andrew Bromage ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: help needed for adding isWHNF primop to 5.00.2
| I would like to add a primitive to GHC 5.00.2 of the form: | | isWHNF :: a - Bool One might be inclined to ask what for? Such a primitive is probably difficult to implement, given the variety of GHC's closures, From reading the documentation that comes with GHC and glancing over the source code, I came to these set of assumptions, please correct me if I am wrong: - values of unpointed types are never in WHNF - values of pointed types may be in WHNF, in particular: - data constructors are in WHNF - partial applications are in WHNF - functions are in WHNF - thunks are not in WHNF (this list is probably not exhaustive as you say, but I am happy with this set of definitions for the moment) and is potentially dangerous -- you could conceivably break referential transparency (?) With the type that I have specified above, yes, it is _very dangerous_ when used without caution. I do not intend for this feature to be used widely in everyday programming. Its probably not terribly useful for most tasks either. I can also imagine it could interact badly with the complexities of GHC's simplifer. This is something I do not know. In the end I may define it with this type: isWHNF :: a - IO Bool as Simon Marlow suggested, indeed this was my original intention, but I am new to the internals of GHC and thought it might be easier to get the unsafe one working first. For my own purposes the unsafe version is what I want. However, the version in the IO monad looks more reasonable, and I can get the unsafe version with unsafePerformIO, whilst maybe requiring some pragmas to help the simplifier out? What would you hope to gain from such a thing? Perhaps you have some wider purpose which could be achieved some other way? I want it for the purposes of meta-programming, and also for debugging since that is what I am working on. At the end of a computation (that results in a value of pointed type, say) I want to know to what extent expressions were evaluated: foo xs = take 3 xs ... foo [4..] ... debugger foo [4,5,6,_ = [4,5,6] Since I am inspecting things after the computation is complete, I should be able to rely on the information from isWHNF. I don't think that the scheme that HOOD uses is right for me, since the overheads would be too costly (I don't want to log every reduction in my program just in case I might need to debug a branch of the computation later on). If you like, what I am doing is a post-mortem inspection of (some) values generated by a program. This is quite standard for declarative debuggers for non-strict languages. I can do this in HUGS via the HugsInternals interface, and I think that it is also possible in NHC too. I'm eager to hear you comments and suggestions, and I appreciate the feedback that I have received so far. Cheers, Bernie. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users