[Haskell-cafe] separate input calculation output

Thomas Engel thomas.engel1 at gmx.net
Tue Mar 25 08:03:55 EDT 2008

Hi Robert

> (I think I know enough haskell to answer this, but I may be telling you 
> all the wrong things.)
Why? What's wrong?
> You'll have to pass the values through, though this can be hidden to  
> some extent. Try changing your functions to have types
> type Input = (Float, Float, ...)
> type Output = (Float, Float, ...)
> inputvalues :: IO Input     -- add a "return (ve,de,...)" to the end
> compute :: Input -> Output

How can I combine several function (calculations) in this function?
> outputvalues :: Output -> IO ()
> You could then wrap them in
> main :: IO ()
> main = do input <- inputvalues
>           outputvalues (compute input)
> This should do what you want.

Thank's for your hints.

> It might be improved upon by using data types with appropriately named  
> fields instead of tuples so as to keep your variable names around.

Can you give me an example how do to it with named fields?



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080325/2513dc70/attachment.bin

More information about the Haskell-Cafe mailing list