[Haskell-cafe] separate input calculation output
ketil at malde.org
Tue Mar 25 06:10:36 EDT 2008
Thomas Engel <thomas.engel1 at gmx.net> writes:
> My problem is: How can I get the input values into the calculations and back
> the result to the output.
> In an other language I would use global variables for this.
That would be bad style.
> An other point is that I want to separate the input from the calculations and
> the output.
> So what should I use in haskell?
I think your pseudocode is right on track.
> inputvalues :: IO ()
The most obvious way to do it would be to define
data Input = ...
data Output = ...
input_values :: IO Input
calculate :: Input -> Output
ouput_values :: Output -> IO ()
main = do i <- input_values
let o = calculate i
main = output_values . calculate =<< input_values
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe