Bram Neijt | 11 Aug 20:41 2014
Picon

Any tips on "doing it right" for a small program?

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:
CMDPATTERN="$ <at> "
while [[ "`pgrep --count --full "$CMDPATTERN"`" -gt 1 ]]; do
    sleep 5
done

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?
- 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)
(Continue reading)

Mateusz Kowalczyk | 11 Aug 20:56 2014
Picon

Re: Any tips on "doing it right" for a small program?

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:
> CMDPATTERN="$ <at> "
> while [[ "`pgrep --count --full "$CMDPATTERN"`" -gt 1 ]]; do
>     sleep 5
> done
> 
> 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 [1].

(Continue reading)

David Virebayre | 12 Aug 08:31 2014
Picon

Re: Any tips on "doing it right" for a small program?

2014-08-11 20:41 GMT+02:00 Bram Neijt <bneijt <at> gmail.com>:
>
> Dear reader,
...
> Also if you have projects you want to point to for inspiration, I'd be
> happy to take a look.

Hello,

Not really projects, but seeing your post I remembered Donal Stewart's
blog, especially:

http://donsbot.wordpress.com/2006/12/18/programming-haskell-argument-handling-and-a-complete-cat/
http://donsbot.wordpress.com/2007/03/10/practical-haskell-shell-scripting-with-error-handling-and-privilege-separation/

It's quite old, but I thought it was relevant.

Cheers,

David.

Gmane