(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| sealed trait Interact[A] | |
| case class Ask(prompt: String) | |
| extends Interact[String] | |
| case class Tell(msg: String) | |
| extends Interact[Unit] | |
| trait Monad[M[_]] { | |
| def pure[A](a: A): M[A] | 
| // In real life, it's great that stuff gets restarted when it fails. | |
| // In testing, we'd rather know that it failed. | |
| import akka.actor._ | |
| class DyingActor extends Actor { | |
| def receive = { case "die" => throw new Exception("poo") } | |
| } | |
| // Default config, everything restarts automatically | |
| val system = ActorSystem("ordinary") | 
| // I was reading through these examples: http://apocalisp.wordpress.com/2010/06/08/type-level-programming-in-scala/ | |
| // and I thought it would be nice to more quickly get to something useful, to show the power of the techniques. | |
| object SizedListExample { | |
| // Type of all Non-negative integers | |
| sealed trait Nat | |
| // This is zero. | |
| sealed trait _0 extends Nat | |
| // Successor to some non-negative number | |
| sealed trait Succ[N <: Nat] extends Nat | 
This gist has been upgraded to a blog post here.
Find it here: https://github.com/bitemyapp/learnhaskell
| import scala.language.experimental.macros | |
| import scala.reflect.macros.Context | |
| import shapeless._ | |
| object NatExample { | |
| def toNat(n: Int): Any = macro toNat_impl | |
| def toNat_impl(c: Context)(n: c.Expr[Int]) = { | |
| import c.universe._ | 
| import akka.actor.Actor | |
| import akka.actor.ActorSystem | |
| import akka.agent.Agent | |
| import com.typesafe.config.ConfigFactory | |
| import akka.event.Logging | |
| import akka.actor.Props | |
| import kafka.utils.Utils | |
| import java.nio.ByteBuffer |