This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder