RE: ghc feature request: core notes
Hal, OK. If you want to change CoreSyn.Note to have an extra constructor, thus: data Note = SCC CostCentre | Coerce Type Type | InlineMe | InlineCall | NoteString String -- NEW and check that the rest of the compiler does something sensible with NoteString, I do not object. There are only 12 lines of the compiler than mention InlineCall, for example, so I expect NoteString would be similarly low-impact. [Incidentally, InlineCall is an undocumented feature. You can write inline f x to mean the same as (f x), except that this particular call to f will be inlined.] Simon | -----Original Message----- | From: Alastair Reid [mailto:alastair@reid-consulting-uk.ltd.uk] | Sent: 06 February 2003 11:28 | To: Simon Peyton-Jones | Cc: Hal Daume III; GHC Users Mailing List | Subject: Re: ghc feature request: core notes | | | "Hal Daume III" <hdaume@ISI.EDU> writes: | > I'm not sure how "generally useful" this would be, but I would | > find it useful to be able to attach notes to core expressions from | > the Haskell code. The idea being something along the lines of a | > code annotation like a pragma. [...] | | Simon Peyton-Jones <simonpj@microsoft.com> writes: | > [...] There is an annotation facility in Core, but it's easy for the notes | > to be discarded. So if they are conveying important info, it might | > easily get lost... and if not, what's it doing there in the first | > place. What do you expect to happen to these annotations? [...] | | It seems like _scc_ is (almost) exactly what you need here. When used | for profiling, you mark subexpressions you want profiled and ghc takes | care to preserve and propagate them in a semantically meaningful way. | Any _scc_ annotations that ghc chooses to drop can be reported as | bugs :-) | | I say "almost" because what the semantics used when profiling may not | be the right ones for your purposes. (I'm being vague because I don't | know your purposes.) | | Naturally, you'd want to be able to use these notes independently of | profiling - which can probably be done with a little preprocessor | hackery. Assuming that the 1st argument to 'NOTE' is a literal string | in the following: | | #ifdef TRACK_NOTES | #define NOTE(x,y) (_scc_ "<NOTE " x ">" (y)) | #else | #define NOTE(x,y) {- nothing -} | #endif | | -- | Alastair Reid
Hi, when toying around with GHCi, I got a bunch of Prelude> :r phase `Literate pre-processor' failed (exitcode = 1) Prelude> :l Hist phase `Literate pre-processor' failed (exitcode = 1) ghc -c -Wall didn't find anything suspicious, and in the end, exiting and restarting ghci did the trick. I've no idea what trigged this, perhaps running out of file handles? Just in case you'd like to know, -kzm -- If I haven't seen further, it is by standing in the footprints of giants
ketil@ii.uib.no (Ketil Z. Malde) writes: ketil@ii.uib.no (Ketil Z. Malde) writes:
Prelude> :r phase `Literate pre-processor' failed (exitcode = 1)
I've no idea what trigged this, perhaps running out of file handles?
I forgot: GHC version 5.04.1. It seems that this is definitely trigged by running out of file handles, so apparently, I did have an idea. ==== The following code runs out of file handles, so I am seeking enlightenment as to why.
-- | add data from a file to the histogram addFile :: FiniteMap String Int -> String -> IO (FiniteMap String Int) addFile fm name = do x <- readFile name return (addHist fm x)
-- | add data from all files in a directory to the histogram addDir :: FiniteMap String Int -> String -> IO (FiniteMap String Int) addDir fm dir = do dc <- getDirectoryContents dir fs <- filterM doesFileExist (map ((dir++"/")++) dc) foldM addFile fm fs
Running addDir on a directory with few hundred files trigs it. Shouldn't all of each file's contents be consumed by each addFile, and thus the handle be released? -kzm -- If I haven't seen further, it is by standing in the footprints of giants
I appreciate this may have been covered before, but i'm struggling to get the types right for the following functions: firstly I have a function I want to be passed an MArray (so the function itself is polymorphic and independant of the type of array used). This has a type similar to: fn1 :: MArray a Int m => a (Int,Int) Int -> m () now I want to produce a wrapper function to provide an MArray of a given type, and freeze the result into a non-mutable array, so I have a function like: wrapper :: MArray (STUArray s) Int (ST s) => ST s (Array (Int,Int) Int) wrapper = do d <- newArray ((0,0),(10,10)) 0 fn1 d unsafeFreeze d However the problem comes when I try and use runST to run it... runMatrix :: Array (Int,Int) Int runMatrix = runST $ wrapper This is becase 's' escapes Expected: ST s a -> b Inferred: (forall s1. ST s1 a) -> a where am I going wrong? Regards, Keean Schupke.
participants (3)
-
Keean -
ketil@ii.uib.no -
Simon Peyton-Jones