module StackMTest where import StackM import Control.Monad import Control.Monad.Trans import System.IO import System.Random add :: Num a => StackM a IO () add = do x <- popM y <- popM pushM (x + y) throwTenDie :: StackM Int IO () throwTenDie = lift (getStdRandom (randomR (1, 10))) >>= pushM stackMTest :: StackM Int IO Int stackMTest = do pushNumber pushNumber throwTenDie add add popM where pushNumber = do text <- lift $ getLine pushM (read text) main :: IO () main = runStackM stackMTest >>= print