Previous month:
June 2007
Next month:
November 2008

September 2007

More on Haskell DSL

In an earlier post, partial make replacement, I developed a small Haskell based DSL to express GNU make like rules. In this post, I take the idea further to support multiple dependencies per target.

testO = (return ["test.c", "test.h"]) ->> ccompile >>- "test.o"

testExe = testO ->> link >>- "test.exe"

main = testExe

The above example, expresses in a simple way, that test.o depends on test.c and test.h and can be "made" using ccompile (C compilation). Similarly, test.exe depends on test.o and can be generated by linking test.o. Checkout the Hmake module (30 lines, including the definition of ccompile and link) and try it out yourself. It now properly checks if a target is out of date with its dependency before trying to build to the target.

Compare the above with the elaborate topological sort based ermake implementation (232 lines) using erlang.

With the Haskell module above, one can even build multiple targets in parallel by using forkIO (part of the Concurrent Haskell).