Re: [Haskell-cafe] Avoiding boilerplate retrieving GetOpt cmd line args

2007-07-27 Thread Andrea Rossato
On Thu, Jul 26, 2007 at 10:25:06PM -0700, Dave Bayer wrote: Ok, I'm writing a command line tool, using System.Console.GetOpt to handle command line arguments. My Flags structure so far is data Flag = Filter String | DateFormat String | DocStart String | DocEnd

Re: [Haskell-cafe] Avoiding boilerplate retrieving GetOpt cmd line args

2007-07-27 Thread Neil Mitchell
Hi Why not: data Flag = Filter String | DateFormat String | DocStart String | DocEnd String Becomes: data Flag = Flag Key String data Key = Filter | DateFormat | DocStart | DocEnd getString :: Flag - Key - String getString (Flag x y) key = if key == x then y else You can easily

Re: [Haskell-cafe] Avoiding boilerplate retrieving GetOpt cmd line args

2007-07-27 Thread Jonathan Cast
On Friday 27 July 2007, Dave Bayer wrote: Ok, I'm writing a command line tool, using System.Console.GetOpt to handle command line arguments. My Flags structure so far is data Flag = Filter String | DateFormat String | DocStart String | DocEnd String ... and I

[Haskell-cafe] Avoiding boilerplate retrieving GetOpt cmd line args

2007-07-26 Thread Dave Bayer
Ok, I'm writing a command line tool, using System.Console.GetOpt to handle command line arguments. My Flags structure so far is data Flag = Filter String | DateFormat String | DocStart String | DocEnd String ... and I want to write accessor functions that return the strings

Re: [Haskell-cafe] Avoiding boilerplate retrieving GetOpt cmd line args

2007-07-26 Thread Levi Stephen
Hi, Not sure if this will help avoid the boilerplate, but I've always liked the approach at http://leiffrenzel.de/papers/commandline-options-in-haskell.html (particularly the section Towards a higher level) for being able to specify defaults. It's the best resource I've found on command line