[Haskell-cafe] IO platform for testing

Matej 'Yin' Gagyi yin at atom.sk
Sun Jul 17 15:41:50 EDT 2005


Isaac Jones wrote:

>yin <yin at atom.sk> writes:
>
>
>>./bundle01 <cmd> <arg1> <arg2> ...
>>
>>I more apoarches, but no one worked. Now I tried this:
>>  
>>   m01_mod :: Int -> Int -> Int
>>
>
>What's m01?  You define b01 below:
>
>
oops! "m01" propably is a halucination of my keyboard :)

>>   main = do
>>       (cmd:ss) <- getArgs
>>       putStrLn (
>>           if (cmd == "mod") then do
>>
>
>You don't need the "do" here.  Since the type of the entire "if"
>statement is a String (not an IO String) this is an error.
>
>
it looks more like bash... I'm familiar with it...

>>               show (b01_mod (read (ss!!1)) (read (ss!!2)))
>>           else do
>>               "unknown command!")
>>
>>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.

>
>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...

Oh, yeah... solved partialy this problem:

   delta_encode :: [Int] -> [Int]
   delta_encode x:y:zs = x : (deltra_encode ((x + y) : zs))
   delta_encode _ = _ -- Is this correct, I wroted it from my head
   
   delta_decode ...
   ...
   
   main = do
       (cmd:ss) <- getArgs
       putStrLn (
           if (cmd == "encode") then
               show (delta_encode (map (read) ss)
           else if (cmd == "decode")
               "unknown command!")


Thanks!

Matej 'Yin' Gagyi



More information about the Haskell-Cafe mailing list