Some students are having problems installing GHCI. A work-around is to use an online version. However, this is both slower and requires you to revise how you write the code a bit.
https://repl.it/languages/haskell
main.hs
:
module Main where add a b = if a == b then 2 * a else a + b trials = ["Test 1: add 8 and 5: " ++ (show (add 8 5)), "Test 2: add -3 and 4: " ++ (show (add (-3) 4)), "Test 3: add 9 and 9: " ++ (show (add 9 9))] main :: IO () main = putStrLn (show trials)
Run >
button and confirm you get output
like
["Test 1: add 8 and 5: 13","Test 2: add -3 and 4: 1","Test 3: add 9 and 9: 18"]
add
by your own functions.
trials
variable to execute your code against
various cases.
f x = x * x main = putStrLn(show (f 3, f (-1), f 1.2))
Just in case you're having problems, here's what I see: