{-  
    COMS 4995: Parallel Functional Programming, Fall 2025
    Quiz 5: Laziness

    1. Close all devices (phone/laptop, etc). Make sure you have an index card to write on, and a pen/pencil.

    2. PLEASE WRITE YOUR NAME AND UNI AS LEGIBLY AS POSSIBLE

    3. Read the quiz question below, and write your answer on your index card. CIRCLE YOUR ANSWER.

    4. Turn in your card at the table in the front of the room.
-}

-- Consider the following function:
foo :: IO ()
foo = do
    let (x, y) = (8 `div` 4, 6 `div` 0)
        swap a b = (b, a)
    putStrLn "Hello, world!"
    let z = swap x y
    print $ snd z

-- QUESTION:
-- When run, does this function throw a "divide by zero" exception?
-- (reminder: `snd` retrieves the second element of a pair)
-- Answer "yes" or "no".

-- CORRECT ANSWER:
-- No

-- EXPLANATION:
-- The expression 6 `div` 0 is passed around as an unevaluated thunk, but the actual
-- result of the computation is never needed, so Haskell never attempts to evaluate it.