Created
November 4, 2011 20:59
-
-
Save purefn/1340475 to your computer and use it in GitHub Desktop.
IO except handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> import scalaz._, Scalaz._, effects._ | |
| import scalaz._ | |
| import Scalaz._ | |
| import effects._ | |
| scala> val hello = putStrLn("Hello") | |
| hello: scalaz.effects.IO[Unit] = scalaz.effects.IO$$anon$2@401c1b5f | |
| scala> val bad:IO[Unit] = throwIO(new Exception("bad thing")) | |
| bad: scalaz.effects.IO[Unit] = scalaz.effects.IO$$anon$2@1d296aa3 | |
| scala> val by = putStrLn("Goodbye") | |
| by: scalaz.effects.IO[Unit] = scalaz.effects.IO$$anon$2@7147036a | |
| scala> hello >|> bad >|> by except (e => putStrLn(e.getMessage)) unsafePerformIO | |
| Hello | |
| java.lang.Exception: bad thing | |
| at .<init>(<console>:16) | |
| at .<clinit>(<console>) | |
| at .<init>(<console>:11) | |
| at .<clinit>(<console>) | |
| at $print(<console>) | |
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) | |
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
| at java.lang.reflect.Method.invoke(Method.java:616) | |
| at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704) | |
| at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:914) | |
| at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:546) | |
| at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:577) | |
| at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:543) | |
| at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:694) | |
| at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:745) | |
| at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:651) | |
| at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:542) | |
| at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:550) | |
| at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822) | |
| at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:851) | |
| at xsbt.ConsoleInterface.run(ConsoleInterface.scala:51) | |
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) | |
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
| at java.lang.reflect.Method.invoke(Method.java:616) | |
| at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:57) | |
| at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:48) | |
| at sbt.Console.console0$1(Console.scala:23) | |
| at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:24) | |
| at sbt.TrapExit$.executeMain$1(TrapExit.scala:33) | |
| at sbt.TrapExit$$anon$1.run(TrapExit.scala:42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment