[Haskell-cafe] Announce: glome-hs-0.51 (Haskell raytracer, now with type classes)
A new version of my raytracer has been posted: http://syn.cs.pdx.edu/~jsnow/glome/ http://hackage.haskell.org/cgi-bin/hackage-scripts/package/glome-hs-0.51 (This should really be named 0.5.1, but I didn't think of that until after I uploaded it to hackage.) There's not much new functionality, but it now uses type classes for the supported primitives, and has been optimized a bit more. Much of the tutorial I hastily wrote for 0.4.x (http://www.haskell.org/haskellwiki/Glome_tutorial) is now quite out of date. Most of the primitives have been moved to their own module, with the exception of SolidItem (an existential type used to make composite primitives), [SolidItem] (allowing me to treat lists of Solids like single solids), Void (a non-object, equivalent to []::[SolidItem]), and Instance (used for transformations). It might be possible to move those to their own modules as well, but it would require mutual recursion between modules, and that's probably more trouble than it's worth. (I made an attempt at that, but I quickly gave up.) I also gave up on trying to use a global mutable variable to count the number of bounding hierarchy nodes a particular ray hits; instead, I added rayint_debug, which behaves just like rayint (the standard ray-object intersection routine), except that it returns an integer (that I can use to count whatever I like) along with the ray intersection. Using a global counter in this instance would have been much simpler, but I don't think I understand seq well enough to be able to force the increment to actually happen. http://syn.cs.pdx.edu/~jsnow/glome/Screenshot-glome-hs-bih.png The resulting renders can be very useful to determine where Glome is spending most of its time, and to verify that the the bounding interval hierarchy is really doing the right thing. I also added packet tracing, which makes it possible to trace four rays at a time, using a specialized ray intersection method packetint. (This is a common technique to amortize the acceleration structure's memory lookup cost over multiple rays.) It seemed to be a big win when I first implemented it before converting over to type classes, but now it seems to be faster without it, so I probably made a mistake somewhere. A cosmetic change is that Glome now renders into a drawlist instead of directly to the screen, so the whole image doesn't get laboriously re-traced whenever there's window damage. Unfortunately, that means you can't watch as it draws anymore, which was a useful way of knowing which parts of the image were slow to render. I've started looking more seriously into optimization (suggestions welcome). Don Stewart's blog post (http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16#fast) was quite useful, but it seems like there's a lot of arcane knowledge required to understand what's really happening in core code. Is there any better reference than Andrew Tolmach's paper An External Representation for the GHC Core Language (2001) http://citeseer.ist.psu.edu/tolmach01external.html? -jim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HDBC with SQL Server / OBDC
am trying to do a simple DB connection from Haskell to a SQL Server 2005 (on Windows obviously). The DSN name (Nylon) works from C++ but when running the below example (or any other I can think of) ghci crashes. Does anyone know a resolution for this or where the problem can possible be ? GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude :m Database.HDBC Prelude Database.HDBC :m + Database.HDBC.ODBC Prelude Database.HDBC Database.HDBC.ODBC do { conn - connectODBC DSN=Nylon; xs - getTables conn; putStr $ head xs; } Loading package array-0.1.0.0 ... linking ... done. Loading package containers-0.1.0.1 ... linking ... done. Loading package bytestring-0.9.0.1 ... linking ... done. Loading package old-locale-1.0.0.0 ... linking ... done. Loading package old-time-1.0.0.0 ... linking ... done. Loading package mtl-1.1.0.0 ... linking ... done. Loading package HDBC-1.1.4 ... linking ... done. Loading package HDBC-odbc-1.1.4.3 ... linking ... done. CRASH !!! Thanks Morten ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: glome-hs-0.51 (Haskell raytracer, now with type classes)
I've started looking more seriously into optimization (suggestions welcome). Don Stewart's blog post (http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16#fast) was quite useful, but it seems like there's a lot of arcane knowledge required to understand what's really happening in core code. Is there any better reference than Andrew Tolmach's paper An External Representation for the GHC Core Language (2001) http://citeseer.ist.psu.edu/tolmach01external.html? As SPJ says, it is just a simple functional language (with unlifted and lifted types). The problem is probably more the syntax, than Core itself. There's a new paper about the core type system, http://research.microsoft.com/%7Esimonpj/papers/ext%2Df/ Otherwise, Andrew's paper is still a reasonable reference. I'd install ghc-core too, which cleans up the output somewhat, and helps with syntax highlighting. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Rotating backdrop (aka learning Haskell)
On Tue, May 20, 2008 at 09:15:57AM +0100, Yann Golanski wrote: 1- Get a list out of a file: I managed to do that using the following: parseImageFile :: FilePath - IO [String] parseImageFile file = do inpStr - readFile file return $ filter (/=) (breaks (=='\n') inpStr) Note that there is a standard function lines which splits a string into lines. Nice, simple and I understand what it is doing. 2- Get a random element from a list and remove it: Okay, this I understand less well. I looked at the solutions of problems 23 and 20 in http://www.haskell.org/haskellwiki/99_questions so there is a skeleton there. However, my list is IO [String] Hum, monads. Any pointers as to how to do that? import System.Random removeRandomElement :: [a] - IO (a, [a]) removeRandomElement l = do i - randomRIO (0, length l - 1) return (removeAt i l) where removeAt is from problem 20 above. And you use it like anything else in the IO monad: do ... images - parseImageFile ... ... (chosen, rest) - removeRandomElement images ... 3- Wait and do something later How, I have no idea how to do that! Help? Control.Concurrent.threadDelay is the simplest way to make a thread sleep for a while. However, if you're using some GUI library, you may want to use the library's own timers. 4- I guess that progress bars and updating text will be somewhere in the GUI (I chose wxHaskell)... Again, no idea where. I'm not familiar with wxHaskell, sorry. 5- How do you call an external program in Haskell? Either xv or Esetroot will do the job of displaying the image. Is there a Haskell native way to do that? There is a direct X11 library for Haskell, but you're probably better off just calling an external program. See the System.Process module. Hope this helps. Lauri ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] library for drawing charts
Peter wrote: Has anyone got some code for drawing charts? I don't mean graphs of functions, ala http://dockerz.net/twd/HaskellCharts ... I would like something that can generate PNGs in memory, i.e. not directly to a file. The library at the above URL supports a range of backends through the (nice to use) cairo graphics API. In memory images are supported. Also, it's by no means just graphs of functions - that just happens to be several of the demos. I'd like 2D pie charts, bar charts and something like a google-o-meter. An the moment it does line charts and a few variants of these. I'll add pie and bar charts when I need them - patches in the meantime gratefully accepted. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Has anyone worked on checking SQL-queries at compile time?
Yes, I know about haskelldb.. But some more advanced optimizations can't be expressed.. so I'd like to ask if someone has done some work in the other direction not ensuring type safety by using the haskell type system to derive SQL queries but to use template haskell to derive functions from given SQL queries thereby checking them for syntax error ? It be a little bit like SQLJ (Java tool for db connectivity) Eg $(q SELECT '2', 4) should result in [(String, Int)] and $(q INSERT INTO foo (2, ?1, ?2) ) should result in Int - whatever type ?1 is - whatever type ?2 is - IO () Ideally this would not only result in a query but in a prepared statement. I have no clue how much RDBMS such as Postgresql provide some help determining type of parameters or results without acutally doing a query (but bcause Postgresql provides transactions this should not be a problem) I see the following benefits: You can use your existing SQL- Knowledge and don't have to dive into deep type hackery yet gettitng as much type safety as possible Marc Weber ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HDBC with SQL Server / OBDC
On Sun, 25 May 2008, Morten Holm Pedersen wrote: am trying to do a simple DB connection from Haskell to a SQL Server 2005 (on Windows obviously). The DSN name (Nylon) works from C++ but when running the below example (or any other I can think of) ghci crashes. I have been having the same (or similar) problem with HDBC and SQL Server. I have no problem using HDBC and SQLite on Windows, and also have no problems with perl's DBI and DBD::ODBC connecting to the SQL Server database with the same DSN. But I don't know where to point the finger, and I don't know what to do next. It does seem strange that there is no error message when ghci crashes. -- Dr Bean Autonomous language learning: My next project after overseeing the making of laborers into athletes. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe