module Failure where import Prelude hiding (drop,max,seq) -- -- * A one-dimensional airplane simulator -- -- | The height of the airplane. type Altitude = Int -- | The maximum altitude of the plane. max :: Altitude max = 1000 -- | Go up. rise :: Int -> Altitude -> Maybe Altitude rise x a | a' <= max = Just a' | otherwise = Nothing where a' = a + x -- | Go down. drop :: Int -> Altitude -> Maybe Altitude drop x a | a' > 0 = Just a' | otherwise = Nothing where a' = a - x -- | Do a loopty-loop: rise 200, drop 300, rise 50. loop :: Altitude -> Maybe Altitude loop a = case rise 200 a of Nothing -> Nothing Just a2 -> case drop 300 a2 of Nothing -> Nothing Just a3 -> rise 50 a3 -- | Sequence an action after another result. seq = undefined -- | Do a loopty-loop using our seq function. loopS :: Altitude -> Maybe Altitude loopS a = undefined -- | Do a loopty-loop in monadic style. loopM :: Altitude -> Maybe Altitude loopM a = undefined -- | Do a whole stunt show starting from the ground: -- * start at 0 -- * rise 400 -- * do two loopty-loops -- * rise 400 -- * do two more loopty-loops stuntM :: Maybe Altitude stuntM = undefined