iterTIO] 39 _ <- WriterT.writerT(IO(List(s"received divisor $dvsor, ready to divide ..."),dvdn)) 40 quot <- div(dvdn.toInt, dvsor.toInt).except(e => IO({println(e.getMessage());-99})).liftM[WriterTIO] 41 _ <- if (quot < 0) WriterT.writerT((List(s"divide by zero Error!!!"),-99).point[IO]) else putLn(s"the result:$quot").liftM[WriterTIO] 42 } yield (quot) 43
44
45 } 46
47 object IOMonadDemo extends App { 48 import IOMonadPrg._ 49 // ioprg.unsafePerformIO() 50 //optionIOprg.run.unsafePerformIO()
51 println(writerIOprg.run.unsafePerformIO()) 52 }
|