Sven Panne <[EMAIL PROTECTED]> writes:

> Isaac Jones wrote:
>> While you're at it, I had a thought of writing a simple function for
>> commands:
>> commandMain :: (String, IO ()) -> IO ()
>> which just grabs the non-flag arguments and executes an action
>> depending on the command. [...]

Sorry, I got the type wrong above :(

> Could you explain this a bit please? I don't fully understand what the
> commandMain should do.

Sure.

The idea is to make it really easy to write a simple command-line
application.  

commandMain :: [(String, IO ())] -> IO ()


main = commandMain [("clean", system "rm -rf build"),
                    ("help", putStrLn "There's no help for you."),
                    ("build", system "ghc --make foo.hs")]

The basic observation is that getOpt doesn't do much for the
"commands" part of an application like cabal or darcs.  This isn't the
way to fix that, since this is far too simple for anything but a toy
application, but it might be interesting to look at a few users of
getOpt and see if it's possible to capture a usage pattern in a
library.


peace,

  isaac
_______________________________________________
Cvs-libraries mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to