Re: [Haskell-cafe] embedded build language?

2007-06-19 Thread Tomasz Zielonka
[I hope you don't mind that I send this letter to haskell-cafe too.
I thought someone else might be interested.]

On Mon, Jun 18, 2007 at 10:52:40AM -0700, Greg Fitzgerald wrote:
 first let's see if anybody likes the general idea
 Would you mind describing the role of Depends.hs in your architecture?

After parsing the target file name, you have to list the files
this target depends on. This list is used by the engine to
check if a rebuild is neccesary, or if some required files
are missing.

To add a file to the dependency list, you call require in Depends
monad. require returns the file name it was given, so you can do
things like:

matchExact prog $ do
o_files - sequence
[ require a.o
, require b.o
, require c.o
]
return $ do
system (gcc -o prog  ++ unwords o_files)

The Writer part of the Depends is used to gather the list. In the
example above, you could also use listen:
listen :: (MonadWriter w m) = m a - m (a, w)
but I'm not sure if it's good to expose the MonadWriter interface.
I think I will provide my version of listen in Depends anyway.

The Reader part is currently used for a very simple thing - it supplies
the target name as a hidden parameter. This allows for an easy way to
get the target name regardless of the matching mechanism used.

 How did you decide on using the Reader and Writer monads?

This was the most natural, and the easiest, choice.

 If you have multiple matching rules, should one take precedence?

Right now in such situation an error will be raised. This of course may
be insufficient in some cases. Depending on the circumstances, you may
want to:
- raise an error (like now)
- choose one of the rules, perhaps based on some priorities or policies,
  like most specific first
- merge the rules, somehow
I haven't thought about those issues too much, but I would prefer to
allow the rule author to decide.

Best regards
Tomek
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] embedded build language?

2007-06-16 Thread Tomasz Zielonka
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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] embedded build language?

2007-06-15 Thread 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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] embedded build language?

2007-06-15 Thread Greg Fitzgerald

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 [EMAIL PROTECTED] wrote:


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

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] embedded build language?

2007-06-14 Thread Greg Fitzgerald

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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] embedded build language?

2007-06-14 Thread Bryan O'Sullivan

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

b
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe