Skip to content

Instantly share code, notes, and snippets.

View tomwadeson's full-sized avatar

Tom Wadeson tomwadeson

View GitHub Profile
module HarryPotter where
import qualified Data.Map.Strict as Map
import Data.Maybe (catMaybes)
type Copies = Int
type Discount = Double
type Price = Double
type DiscountScheme = Int -> Discount
scala> case class Callback[A](f: (A => Unit) => Unit) {
| def map[B](g: A => B): Callback[B] = Callback { (h: B => Unit) => f(a => h(g(a))) }
| def flatMap[B](g: A => Callback[B]): Callback[B] = Callback { (h: B => Unit) => f(a => g(a).f(b => h(b))) }
| }
defined class Callback