Skip to content

Instantly share code, notes, and snippets.

Franklin Chen FranklinChen

Block or report user

Report or block FranklinChen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@FranklinChen
FranklinChen / playground.rs
Created Nov 15, 2015 — forked from anonymous/playground.rs
Shared via Rust Playground
View playground.rs
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 Nov 15, 2015 — forked from anonymous/playground.rs
Shared via Rust Playground
View playground.rs
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();
View algebras.hs
{-# 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) }
View gist:ec627b32670dd31f4028
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]
You can’t perform that action at this time.