[Haskell-cafe] IO platform for testing
ijones at syntaxpolice.org
Mon Jul 18 01:35:55 EDT 2005
Matej 'Yin' Gagyi <yin at atom.sk> writes:
>>>Please, send me somethung like this (I need to understand it). I need
>>>runing more <cmd>s and with various argument counts and types. All
>>>functions "in a bundle" should be in one file.
> I need a module Main. So, when I write some function and save it in
> file funcsXX.hs and compile all the files, the result should be a
> program, which will execute my functions. I need it to test these
> functions, because I just started to learn Haskell.
That is correct. I'm not sure what your question is. After writing
this file (the beginning should read module Main where...) use GHC to
compile it; lets call it yinTest:
ghc --make YourFile.hs -o yinTest
now hopefully "./yintest mod 4 2" will do the right thing!
>>Otherwise, looks roughly correct to me... The program will crash with
>>a meaningless error if they don't enter any args.
> Should I handle incorect situations? How does exception in Haskell work...
When I'm writing a small program like this, I usually write something
main = do
args <- getArgs
case args of
 -> helpMsg -- empty list
["mod",arg1,arg2] -> ...
_ -> helpMsg -- any other inputs
helpMsg = error "unknown command. Known commands are: 'mod'"
More information about the Haskell-Cafe