Skip to content

Instantly share code, notes, and snippets.

View FranklinChen's full-sized avatar

Franklin Chen FranklinChen

View GitHub Profile
@FranklinChen
FranklinChen / playground.rs
Created November 15, 2015 06:11 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::sync::{Arc, Mutex};
use std::thread;
struct Toaster {
count: u32
}
impl Toaster {
fn new() -> Toaster {
Toaster { count: 0 }
@FranklinChen
FranklinChen / playground.rs
Last active November 15, 2015 05:58 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::thread::{spawn, sleep_ms};
use std::sync::mpsc::channel;
fn main() {
// Names of attendees.
let names = vec![format!("A"), format!("B"), format!("C"), format!("D"), format!("E")];
// Create a channel to communicate between attendees and the toaster.
let (toaster_tx, toaster_rx) = channel();
{-# LANGUAGE RankNTypes, DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
module Main where
import Criterion.Main (defaultMain, bench, bgroup, nf)
--------------------------------------------------------------------------------
-- Fixed points of a functor
newtype Mu f = Mu { muF :: f (Mu f) }
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]