
Has anyone embedded a build language in Haskell? Something like Rakehttp://rake.rubyforge.org/is to Ruby, but in Haskell or any statically-typed functional language. Thanks, Greg

Greg Fitzgerald wrote:
Has anyone embedded a build language in Haskell? Something like Rake http://rake.rubyforge.org/ is to Ruby, but in Haskell or any statically-typed functional language.
The closest I've seen is a tiny snippet from a blog posting: http://ashish.typepad.com/ashishs_niti/2007/06/another_dsl_emb.html

On Thu, Jun 14, 2007 at 05:55:46PM -0700, Greg Fitzgerald wrote:
Has anyone embedded a build language in Haskell? Something like Rakehttp://rake.rubyforge.org/is to Ruby, but in Haskell or any statically-typed functional language.
I have. It consists of such components: - A type for build rules type Rule = FilePath -> Maybe (BuildMonad (IO ())) newtype BuildMonad a = BuildMonad { runBuildMonad :: WriterT [FilePath] IO a } deriving (Monad, MonadWriter [FilePath]) Every rule has three levels: - matching target file names :: FilePath -> Maybe a - generating dependencies :: WriterT [FilePath] m a - target building :: IO () The levels are nested in a way that allows to use variables bound on one level in the levels below. - An simple rule execution engine - takes a list of rules and tries to build given targets taking care of dependencies - A small library of useful functions, eg. for using temporary files with automatic renaming on successful completion (so you don't end up with partially built targets). - A small Template Haskell library for Perl-like string interpolation to help constructing shell commands If you want to see the code I will try to release it (it's in a company's project), but it's quite small and IMHO the nicest thing in it is the overall idea. It's quite heavy for simple uses, but in more complicated cases it allows things which are nearly (or literally) impossible in GNU make. Best regards Tomek

Tomek,
If you want to see the code I will try to release it I'm very interested.
Thanks,
Greg
On 6/15/07, Tomasz Zielonka
On Thu, Jun 14, 2007 at 05:55:46PM -0700, Greg Fitzgerald wrote:
Has anyone embedded a build language in Haskell? Something like Rakehttp://rake.rubyforge.org/is to Ruby, but in Haskell or any statically-typed functional language.
I have. It consists of such components:
- A type for build rules
type Rule = FilePath -> Maybe (BuildMonad (IO ()))
newtype BuildMonad a = BuildMonad { runBuildMonad :: WriterT [FilePath] IO a } deriving (Monad, MonadWriter [FilePath])
Every rule has three levels: - matching target file names :: FilePath -> Maybe a - generating dependencies :: WriterT [FilePath] m a - target building :: IO () The levels are nested in a way that allows to use variables bound on one level in the levels below.
- An simple rule execution engine - takes a list of rules and tries to build given targets taking care of dependencies
- A small library of useful functions, eg. for using temporary files with automatic renaming on successful completion (so you don't end up with partially built targets).
- A small Template Haskell library for Perl-like string interpolation to help constructing shell commands
If you want to see the code I will try to release it (it's in a company's project), but it's quite small and IMHO the nicest thing in it is the overall idea. It's quite heavy for simple uses, but in more complicated cases it allows things which are nearly (or literally) impossible in GNU make.
Best regards Tomek

On Fri, Jun 15, 2007 at 02:13:18PM -0700, Greg Fitzgerald wrote:
Tomek,
If you want to see the code I will try to release it I'm very interested.
It seems I started rewriting this from scratch at home, so I can easily release it. Here is the darcs repo: http://www.uncurry.com/repos/HBuild/ It contains only the build engine stuff, and I think it's just as it should be. There is no license yet, but I can quickly fix that. Example of use: $ ./Example repeat37.txt building a.txt building repeat37.txt $ ./Example b.txt repeat37.txt building b.txt $ rm a.txt $ ./Example b.txt repeat37.txt building a.txt rebuilding b.txt rebuilding repeat37.txt $ touch a.txt $ ./Example b.txt repeat37.txt rebuilding b.txt rebuilding repeat37.txt You will see it's really simple. I can think about some improvements and optimisations, but first let's see if anybody likes the general idea. I will be very grateful for any comments. Best regards Tomek
participants (3)
-
Bryan O'Sullivan
-
Greg Fitzgerald
-
Tomasz Zielonka