[Haskell-cafe] Re: EDSL for Makefile

Neil Mitchell ndmitchell at gmail.com
Mon Oct 4 09:26:30 EDT 2010


> Telling from the video and the slide, Neil's make system is actually
> really cool. Indeed something I would really enjoy to use.

Thanks :-)

> So you use "want" and "need" to tell the system about the static and
> dynamic dependencies.
> The "want" at the beginning just tells which targets to start.
> Since you may want to choose your task via command line, you actually
> would want to do something like:
> main = do
>    wantDefault "file1" =<< getArgs
>    "file1" *> ...

Yep, that's certainly one way of doing it (and a very natural way of doing it).

> Since using String everywhere for dependencies can lead to errors, it
> is always a good idea to replace the strings by constants you can
> reuse.

You can also use wildcards everywhere (i.e. have a rule for *.exe),
and then you only give each file once - but anyone duplicating any
complex thing like a string more than once should either use a let or
write a combinator on top of it - either works just fine.

> Shake is more kind of a library. If you want a more make-like System
> you can even write a preprocessor (like the haskell sinatra clone
> "bird"), which even looks for your target symbols and then generates a
> haskell file with target symbols replaced by Strings.

It doesn't even need to generate a Haskell file, you can sequence
these operations dynamically in a Monad and use Shake as a backend
target for anything. Haskell is great :-)

> I hope the space leaks will be fixed in the future, so one can even
> write long running processes which automatically detect changes and
> rerun without user interaction and much more.

Yes, although in practice you could probably already do it without
issue. I think the space leak is incredibly shallow, and could be
fixed in a few hours.

> I actually wonder about the semantic differences between want and
> need. Is need used to tell about dynamic dependencies and want for
> static dependencies?

You could always do:

"PHONY" *> \_ -> do
   need xs

Instead of want xs, and have the system know about PHONY specially.
want is a way of kicking off the initial set, and need is doing it
after that - the real difference is the monad they run in and nothing
else. The semantic idea is that "want" expresses that you the end user
wants to have these files available, while the rules "need" to have
files available before they continue - it's entirely  possible they
should be overloaded over the two monads.

Thanks, Neil

> On 4 Okt., 05:41, C K Kashyap <ckkash... at gmail.com> wrote:
>> > mention_only_once file action = do
>> >   want [file]
>> >   file *> action
>> > main = mention_only_once "file1" $ \x -> do need ["file2"]
>> >                                            putStrLn "Hello"
>> >                                            putStrLn "World"
>> Thanks Bulat ....
>> I guess even this should work -
>> main = do
>>   let file1="file1"
>>   want [file1]
>>   file1 *> \x -> do
>>     need ["file2"]
>>     putStrLn "Hello"
>>     putStrLn "World"
>> --
>> Regards,
>> Kashyap
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-C... at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list