[Haskell-cafe] Any tips on "doing it right" for a small program?
fuuzetsu at fuuzetsu.co.uk
Mon Aug 11 18:56:16 UTC 2014
On 08/11/2014 08:41 PM, Bram Neijt wrote:
> Dear reader,
> I'm still new to haskell, and decided to convert a simple bash script
> to a full-on-bells-and-whistles Haskell program (as a learning
> experience). As you might guess I could use some help.
> The program is very simple, in Bash it reads:
> while [[ "`pgrep --count --full "$CMDPATTERN"`" -gt 1 ]]; do
> sleep 5
> AKA: while there is a command running with the given string, loop. I
> called this script "after" and use it on the commandline to chain
> commands from different terminals.
> The Haskell version is available at https://github.com/bneijt/after
> What I have done:
> - Add Travis CI
> - Add a first test case using test-framework
> - Add commandline option parsing using "options"
> - Implement a fork-join behavior using parallel-io
> What I would like help with:
> - How to add a --version that reflects the after.cabal version?
You can use the symbols cabal generates at build time. See .
> - Is there a library for what I'm doing in Process.hs (listing running
> processes, etc.)?
> - How to add "-p <pid>" support, so I can do "after -p 129 -p 402"
> (after both pids)
Hm, I don't know. Seems like you could use waitForProcess from the
process package but it doesn't seem to expose a way to create a
ProcessHandle without spawning the process ourselves which is reasonable
I suppose. You might need to implement something yourself. If you find
out how to solve your previous question then this should become easy.
> - Should I move from exitcode-stdio-1.0 to detailed-1.0?
> - Any and all other hints you might have
> Also if you have projects you want to point to for inspiration, I'd be
> happy to take a look.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe