Skip to content

Instantly share code, notes, and snippets.

View ChristopherDavenport's full-sized avatar

Christopher Davenport ChristopherDavenport

View GitHub Profile

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
#!/bin/bash
JENKINS_URL=$1
NODE_NAME=$2
NODE_SLAVE_HOME='/home/build/slave'
EXECUTORS=1
SSH_PORT=22
CRED_ID=$3
LABELS=build
USERID=${USER}
@ChristopherDavenport
ChristopherDavenport / latency.txt
Created January 26, 2017 17:16 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@ChristopherDavenport
ChristopherDavenport / SeqPar.purs
Created February 12, 2017 20:53 — forked from jdegoes/SeqPar.purs
Free applicative in free monad
-- A sequential series of parallel program fragments in `f`:
type SeqPar f a = Free (FreeAp f) a
liftFA :: forall f a. f a -> SeqPar f a
liftFA = pure >>> pure
liftSeq :: forall f a. Free f a -> SeqPar f a
liftSeq fa = foldFree fa liftFA
liftPar :: forall f a. FreeAp f a -> SeqPar f a
package com.example.http4s
import cats.data.OptionT
import cats.effect.Sync
import org.http4s.dsl.impl.Path
import org.http4s.headers.Allow
import org.http4s.{AuthedRoutes, HttpRoutes, Method, Response, Status}
object Route {
def of[F[_]: Sync](pf: PartialFunction[Path, Map[Method, HttpRoutes[F]]]): HttpRoutes[F] = HttpRoutes[F] { req =>