I had to write 3 functions: one to convert Fahrenheit to Celsius, one to convert Celsius to Kelvin and a third that converts Fahrenheit to Kelvin using the two first functions.
I’ve never played with Haskell before so this took me a relatively long amount of time, although now I see that it is pretty simple.
Anyway, I am required to create interactive Haskell programs for the first two functions and use them to compose and executable with pipes in order to get an equivalent to the third function. I have been reading on pipes and it seems simple enough. My main problem seems to be making the functions interactive.
Any help, tips and resources is greatly appreciated!
The
interactfunction should be pretty useful when solving your problem. Because the UNIX convention is that processes should communicate using text (and not numbers, like temperatures), it means that theinteractfunction wraps functions that takeStrings and returnStrings. This means that you have to wrap your fahrenheit/celsius functions in new functions that take and return strings instead of numbers.As an example to get you started, this program upper-cases all strings that are given to it:
You can compile it with:
…and then you can use it (on Linux) by doing this: