Re: [Haskell-cafe] Command line prompt templates

2006-11-23 Thread Donald Bruce Stewart
ithika:
 I was trying to write my own equivalent to Don Stewart's mkcabal but
 ended up getting sidetracked. I made some generalised prompts for use at
 the command line and wanted to get some feedback on them.
 
 The full code can be found at [1] but the basic summary is like this:
 
  prompt :: String - IO String
 
 Simple prompt - supply a question and receive the user's answer.
 
  promptYesNo :: String - Maybe String - IO Bool
 
 A yes/no question, with an optional value to ask about. I suppose this
 could be simplified to just one string.
 
  promptList :: String - [String] - Maybe Integer - IO Integer
 
 Ask the user to choose from a list, where the result is the number
 chosen. The optional value is a default if the user doesn't pick a
 number.
 
  promptListEdit :: String - [String] - Maybe Integer - IO String
 
 As above, but the last option in the list is an invitation to provide
 your own answer. Again the optional value is the default choice if
 nothing else is chosen. The result here is necessarily the string rather
 than the integer cos I didn't want to complicate matters further with
 stuff like Either types.
 
 If you can see any flaws or have any suggestions please let me know!

Looks pretty good, though you use 

case x :: Bool of
True  - ...
False - ...

when
if x then ... else ...

would be preferred.

I wonder if there's a prompt API out there for python or something you
could use for inspiration?

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Command line prompt templates

2006-11-23 Thread Antti-Juhani Kaijanaho
Donald Bruce Stewart wrote:
 Looks pretty good, though you use 
 
 case x :: Bool of
 True  - ...
 False - ...
 
 when
 if x then ... else ...
 
 would be preferred.

Why?  Personally, I find boolean case to feel better wrt layout and I see
no loss of clarity in its use.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe