fork download
  1. -- Ask temperature in Celsius then convert to Fahrenheit
  2.  
  3. temperatureFahrenheit temperatureCelsius = 32 + temperatureCelsius * 9 / 5
  4.  
  5. main = do
  6. putStrLn "What temperature in Celsius?"
  7. c <- getLine
  8. let temperatureCelsius = c :: Int
  9. result <- temperatureFahrenheit temperatureCelsius
  10. putStrLn ("It's " ++ result ++ " in Fahrenheit")
  11.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
20
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:8:30: error:
    • Couldn't match type ‘[Char]’ with ‘Int’
      Expected type: Int
        Actual type: String
    • In the expression: c :: Int
      In an equation for ‘temperatureCelsius’:
          temperatureCelsius = c :: Int
      In the expression:
        do putStrLn "What temperature in Celsius?"
           c <- getLine
           let temperatureCelsius = ...
           result <- temperatureFahrenheit temperatureCelsius
           ....
  |
8 |     let temperatureCelsius = c :: Int
  |                              ^

prog.hs:9:15: error:
    • Couldn't match expected type ‘IO [Char]’ with actual type ‘Int’
    • In a stmt of a 'do' block:
        result <- temperatureFahrenheit temperatureCelsius
      In the expression:
        do putStrLn "What temperature in Celsius?"
           c <- getLine
           let temperatureCelsius = ...
           result <- temperatureFahrenheit temperatureCelsius
           ....
      In an equation for ‘main’:
          main
            = do putStrLn "What temperature in Celsius?"
                 c <- getLine
                 let temperatureCelsius = ...
                 ....
  |
9 |     result <- temperatureFahrenheit temperatureCelsius
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
stdout
Standard output is empty