Vec is Good
Last night I checked out Scott E. Dillard’s Vec library. It’s a good, fast, pure implementation of the basic matrix operations applicable to 3D graphics. Switching to Vec has shaved off quite a bit of time from one of my demo apps and relieved me of the need to maintain my own matrix manipulation code, which was causing me repeated headaches.
It’s very heavy with MPTCs, fundeps, and type families, which will cause ghc to render some pretty inane error messages, but if you’re already accustomed to this then it’s actually very straightforward to use.
May 5, 2009
Posted in: Haskell, RSAGL
One Comment
ANN: priority-sync
Provides cooperative task prioritization.
The priority-sync package on hackage.haskell.org.
$ cabal install priority-sync
$ git clone http://www.downstairspeople.org/git/priority-sync.git
Feedback will be greatly appreciated. This package is a spin-off from my work on roguestar, where I need to do significant background processing while retaining enough resources to perform smooth animation.
April 29, 2009
Posted in: Uncategorized
No Comments
Trends in Profiling Haskell
I spent some time yesterday profiling roguestar. I do this every few months just to see where things stand, and there are always two culprits at the top of roguestar-gl.prof, every single time:
* typeclass dictionary lookups in inner loops
* Rational
In the first case, I think the simplest solution is to INLINE the puppy. Can the ghc inliner be a little bit more aggressive when it sees dictionary lookups? Inliners are tricky business. I’m not sure I see a simple heuristic. Vaguely: leaf functions that require dictionary lookups need to be specialized.
Rational can sneak into an unsuspecting program through realToFrac, and absolutely *kills* performance.
I sit down thinking to myself, “Ok, today I’m going to streamline my Super Mumbo Jumbo Widget and get 15% faster performance,” or some such goal I set for myself. And I run the profiler and 75% of my time is being spent in fromRational . toRational.
April 16, 2009
Posted in: Haskell
5 Comments
Twilight Hero
Here we see our hero fighting a recreant with a kinetic sabre. The material spheres front and left can be used to repair yourself, while a phase rifle is to the right. In unskilled hands, such powerful weapons can more dangerous to the user than enemy.
March 22, 2009
Posted in: Roguestar
No Comments
MaybeArrow?
As I’ve found myself repeatedly writing a bit of code that looked vaguely like this:
get :: SomeArrow String (Maybe Thing)
foo :: [Thing] -> FooThing
. . .
getAToZ :: SomeArrow () (Maybe FooThing)
getAToZ = proc () ->
do m_a <- get -< "a"
m_b <- get -< "b"
. . .
m_z <- get -< "z"
returnA -<
do a <- m_a
b <- m_b
. . .
z <- m_z
return $ foo [a,b . . . z]
It seemed that there would have to be a way to automate this. So I wrote this MaybeArrow (careful, I’m still using 6.8.2 so it’s the old arrows with ‘pure’.). I know that there is already an ErrorArrow. But ErrorArrow as far as I can see requires ArrowChoice, and I’m not doing that. In the MaybeArrow, if an earlier computation throws a Nothing, then later computations are still allowed to perform side effects, although their outputs are snuffed, which is the behavior I want.
I would appreciate any constructive feedback.
If you’re wondering the use case has to do with waiting on several separate pieces of information to arrive from a server and combining them into one output message.
January 4, 2009
Posted in: Haskell
10 Comments

