News aggregator

New version of Glome raytracer

Haskell on Reddit - Mon, 01/27/2014 - 5:07pm

Glome [1] is a raytracer I wrote about six years ago. It's been a long time since the last release; the new version 0.2 is mostly to get it working again with recent versions of GHC.

Glome supports a number of basic primitives including triangles, boxes, cylinders, cones, spheres, and planes and composite primitives including CSG difference and intersection. New types of primitives can be added easily just by defining new instances of the "solid" typeclass. It also uses a BIH-based acceleration structure to efficiently render large scenes.

Glome is split into three packages: GlomeVec [2], a vector library, GlomeTrace [3], a raytracing library, and a front-end viewer program called GlomeView [4]. GlomeView is new, and replaces glome-hs. (The main difference between the two is that GlomeView uses SDL instead of OpenGL.)

Most of the other changes were bug fixes -- there were a handful of bugs that caused CSG objects to render incorrectly.

Another big change is that Glome is now up on github [5], so it should be easier to collaborate if anyone else wants to work on it.

The typical way to use Glome is to edit the file TestScene.hs included with GlomeView, and then re-compile and run the application.

GlomeView does get a decent speedup on multi-core systems. I had hoped that in the time since I'd last worked on Glome that Moore's law (or should we start calling it "Moore's suggestion"?) had caught up to the point where I could render reasonably complex models at interactive framerates, and use Glome as an OpenGL replacement. We're not there yet, though -- I seem to be getting in the neighborhood of 1fps at 720x480 for the kinds of scenes I want to render (thousands of triangles).






submitted by elihu
[link] [4 comments]
Categories: Incoming News

Philip Wadler: Off the Beaten Track: False Starts

Planet Haskell - Mon, 01/27/2014 - 4:01pm

Saturday I had the pleasure to attend Off the Beaten Track, a workshop of POPL 2014.  Every single talk was introduced with the phrase 'And now for something completely different ...'

One talk, by Nada Amin and Tiark Rompf (delivered by Nada), argues that 'papers should expose the sausage-factory of designing calculi, and the minefields in the landscape'.

Ever since Euler (at least), papers in mathematics tend to present a polished solution at the cost of hiding the insights that led to the solution's discovery. Only rarely does one see papers that describe an approach that failed, even though, arguably, knowing what not to do can be as important as knowing what to do.

This leads me to make a suggestion. Every paper is expected to contain sections, where relevant, on
design, implementation, performance, theory, and related work. We should also include, where relevant, a section on 'false starts': research directions that failed to pan out. That is, 'false starts' should be on the checklist of what to cover when first organising a paper. Papers with such material exist, but they are rare; we should make them a common case.

What are your favourite papers that clearly explain a false start?

Categories: Offsite Blogs

Philip Wadler: Take a lawyer’s advice – visit the occupied territories

Planet Haskell - Mon, 01/27/2014 - 2:34pm
Even committed Zionists are beginning to understand that Israel is consistently violating fundamental human rights in Palestine. This article, by a lawyer, focusses on how Palestinian children fare. Spotted via JFJFP.
By David Middleburgh, Jewish Chronicle
January 17, 2014
I have just returned from a three-day tour of the West Bank and east Jerusalem, organised by the pro-Israel, pro-peace organisation, Yachad. The participants were all passionate Zionists and, were it not for some grey hairs and wrinkles, we could have been a youth group. In fact, we were all senior lawyers or individuals with a particular interest in the rule of law.The purpose: to understand the legal context to the occupation. The centrepiece, a unique visit to the IDF military courts that maintain law and order (for Palestinians only) in the West Bank, unique in that we were the first organised group of British Jews to visit the courts. In the course of the tour we met a very broad spectrum of people from representatives of Israeli NGOs, a senior employee of the Yesha Council, which represents settlers, and a senior adviser to Foreign Minister Avigdor Lieberman.
Arrest of childMy conclusions? First, there is no substitute for finding out what is really happening on the ground by visiting and asking difficult questions. I had made numerous assumptions from both Jewish and non-Jewish media, which were simply wrong.Secondly, those who consider that stories of systemic breaches of human rights under the occupation are an anti-Israel myth are deluding themselves.We spent a morning at the military courts observing young Palestinian boys, aged 13-17, being processed, and speaking to their mothers. It is clear that children are invariably arrested in night raids by the army at gunpoint, cuffed and blindfolded and held, often for hours, in that condition, denied access to food, water and toilet facilities, interrogated without being advised of their rights, without a lawyer and without their parents.
Boy arrested by IDF, Nabi Saleh, 2011Military Court Watch, an Israeli NGO, has carried out a detailed forensic review and they found over 50 per cent of children were arrested in night raids and 83 per cent of children blindfolded. All of the children we saw in court were in leg shackles.There was a shocking passivity of the Palestinians we observed at court. Parents and detained children smiled and joked with each other and we did not see a single case of anger. That’s not to say parents did not care that their children were being imprisoned.
Israeli occupation forces detain a Palestinian youth in the West Bank city of Hebron on 22 September 2013, during protests against road closures for the benefit of Jewish settlers. Photo by Mamoun Wazwaz / APA imagesBut conviction rates are 99.7 per cent. The passivity bespeaks a people who have become resigned to their reality. They recognise there is no longer any point in fighting for basic rights. I felt that the court system was clearly a figleaf for a system of arbitrary justice where the guilt of the child is beside the point. The courts are part of a system that effectively keeps Palestinian society in a state of constant fear and uncertainty.So why do the authorities bother with the expense of maintaining the pretence of justice? The answer is that without scrutiny it is possible to pretend that the system is fair. So, defendants are legally represented and proper rules of evidence apply.
Boy arrested on suspicion of throwing stones, Silwan, December 26, 2010. No further information
Arrest of boy, Silwan, 2011. No further information.
A much reproduced photo, for obvious reasons of a police swoop on young boys in Jerusalem, 2010. No further information.Scrape away the veneer, and the charade is exposed with convictions routinely obtained based upon forced confessions and defendants facing remand without bail pending trial for periods in excess of sentences when pleading guilty. No sane defendant would plead not guilty in this Catch 22 situation.I would argue that diaspora Jews who are true friends of Israel have a duty to visit the territories to understand the problem, and then to lobby friends in Israel to strive for a just end to this situation.If we do nothing, can we complain if we awake one day and Israel has sleepwalked into the status of a pariah country?David Middleburgh is a partner in the London firm of Gallant Maxwell solicitors
Categories: Offsite Blogs

New Functional Programming Job Opportunities

haskell-cafe - Mon, 01/27/2014 - 9:00am
Here are some functional programming job opportunities that were posted recently: Haskell Developer at Zalora Cheers, Sean Murphy
Categories: Offsite Discussion

[ANN]: arb-fft 0.1, Fast Fourier transform library

haskell-cafe - Mon, 01/27/2014 - 8:31am
Dear Cafe, I'm happy to announce the first release of arb-fft, a pure Haskell FFT implementation for arbitrary length vectors: This is probably more of pedagogical interest than anything else, since there's a long series of blog articles describing the development of the package, indexed at The package has some interesting features beyond the usual "textbook" powers-of-two FFT algorithm. In particular, it uses a mixed-radix decomposition of composite input lengths, uses Rader's algorithm for large prime factors and has an empirical benchmarking scheme using Criterion for FFT plan selection. The performance of arb-fft is within a factor of 10 of FFTW for most input sizes, which isn't too bad for a pure Haskell with only a relatively limited amount of work done on optimisation. Commentary is very welcome, as are offers to help with any of the tasks listed in the last blog article:
Categories: Offsite Discussion

hoogle - find functions as arrows?

haskell-cafe - Mon, 01/27/2014 - 7:07am
I was surprised that a Hoogle search for: (a -> b) -> (a -> c) -> a -> (b, c) No results found Didn't find this: (&&&)<> :: Arrow a => a b c -> a b c' -> a b (c, c')<> Since functions are arrows; yes? I suppose I can see why it might not, but it seems that it would be nice if it did. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Sky Blue Trades - Mon, 01/27/2014 - 5:32am
Categories: Offsite Blogs

Sky Blue Trades - Mon, 01/27/2014 - 5:32am
Categories: Offsite Blogs

Yesod Web Framework: Initializing data in the foundation datatype

Planet Haskell - Mon, 01/27/2014 - 2:40am

I've added a very short chapter to the Yesod book giving an example of performing initialization before your application starts. The technique isn't complicated (which explains why the chapter is so short), but new users often get stuck trying to find the canonical way to do this. Hopefully this chapter will clarify the issue. If there's anything unclear in the example, please let me know so I can update it.

Below is the current version of the content, though I recommend reading from the link above to ensure you get the newest version of the content.

This example is meant to demonstrate a relatively simple concept: performing some initialization of data to be kept in the foundation datatype. There are various reasons to do this, though the two most important are:

  • Efficiency: by initializing data once, at process startup, you can avoid having to recompute the same value in each request.

  • Persistence: we want to store some information in a mutable location which will be persisted between individual requests. Often times, this is done via an external database, but it can also be done via an in-memory mutable variable.

<aside class="note">

While mutable variables can be a convenient storage mechanism, remember that they have some downsides. If your process dies, you lose your data. Also, if you scale horizontally to more than one process, you’ll need some way to synchronize the data between processes. We’ll punt on both of those issues for this example, but the problems are real. This is one of the reasons Yesod puts such a strong emphasis on using an external database for persistence.


To demonstrate, we’ll implement a very simple website. It will contain a single route, and will serve content stored in a Markdown file. In addition to serving that content, we’ll also display an old-school visitor counter indicating how many visitors have been to the site.

<section id="initializing-foundation-data_step_1_define_your_foundation"> Step 1: define your foundation

We’ve identified two pieces of information to be initialized: the Markdown content to be display on the homepage, and a mutable variable holding the visitor count. Remember that our goal is to perform as much of the work in the initialization phase as possible and thereby avoid performing the same work in the handlers themselves. Therefore, we want to preprocess the Markdown content into HTML. As for the visitor count, a simple IORef should be sufficient. So our foundation data type is:

data App = App { homepageContent :: Html , visitorCount :: IORef Int } </section> <section id="initializing-foundation-data_step_2_use_the_foundation"> Step 2: use the foundation

For this trivial example, we only have one route: the homepage. All we need to do is:

  1. Increment the visitor count.

  2. Get the new visitor count.

  3. Display the Markdown content together with the visitor count.

One trick we’ll use to make the code a bit shorter is to utilize record wildcard syntax: App {..}. This is convenient when we want to deal with a number of different fields in a datatype.

getHomeR :: Handler Html getHomeR = do App {..} <- getYesod currentCount <- liftIO $ atomicModifyIORef visitorCount $ \i -> (i + 1, i + 1) defaultLayout $ do setTitle "Homepage" [whamlet| <article>#{homepageContent} <p>You are visitor number: #{currentCount}. |] </section> <section id="initializing-foundation-data_step_3_create_the_foundation_value"> Step 3: create the foundation value

When we initialize our application, we’ll now need to provide values for the two fields we described above. This is normal IO code, and can perform any arbitrary actions needed. In our case, we need to:

  1. Read the Markdown from the file.

  2. Convert that Markdown to HTML.

  3. Create the visitor counter variable.

The code ends up being just as simple as those steps imply:

main :: IO () main = do rawMarkdown <- TLIO.readFile "" countRef <- newIORef 0 warp 3000 App { homepageContent = markdown def rawMarkdown , visitorCount = countRef } </section> <section id="initializing-foundation-data_conclusion"> Conclusion

There’s no rocket science involved in this example, just very straightforward programming. The purpose of this chapter is to demonstrate the commonly used best practice for achieving these often needed objectives. In your own applications, the initialization steps will likely be much more complicated: setting up database connection pools, starting background jobs to batch process large data, or anything else. After reading this chapter, you should now have a good idea of where to place your application-specific initialization code.

Below is the full source code for the example described above:

{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} import Data.IORef import qualified Data.Text.Lazy.IO as TLIO import Text.Markdown import Yesod data App = App { homepageContent :: Html , visitorCount :: IORef Int } mkYesod "App" [parseRoutes| / HomeR GET |] instance Yesod App getHomeR :: Handler Html getHomeR = do App {..} <- getYesod currentCount <- liftIO $ atomicModifyIORef visitorCount $ \i -> (i + 1, i + 1) defaultLayout $ do setTitle "Homepage" [whamlet| <article>#{homepageContent} <p>You are visitor number: #{currentCount}. |] main :: IO () main = do rawMarkdown <- TLIO.readFile "" countRef <- newIORef 0 warp 3000 App { homepageContent = markdown def rawMarkdown , visitorCount = countRef }
Categories: Offsite Blogs

tasty - Sun, 01/26/2014 - 4:04pm
Categories: Offsite Blogs