Last active
August 29, 2015 13:56
-
-
Save tjweir/9017580 to your computer and use it in GitHub Desktop.
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
| // From Conceptual Mathematics and http://eed3si9n.com/learning-scalaz/Category+theory.html | |
| sealed trait Person {} | |
| case object John extends Person {} | |
| case object Mary extends Person {} | |
| case object Sam extends Person {} | |
| val a: Set[Person] = Set[Person](John, Mary, Sam) | |
| sealed trait Breakfast {} | |
| case object Eggs extends Breakfast {} | |
| case object Oatmeal extends Breakfast {} | |
| case object Toast extends Breakfast {} | |
| case object Coffee extends Breakfast {} | |
| sealed trait Dish {} | |
| case object Mug extends Dish {} | |
| case object Plate extends Dish {} | |
| case object Bowl extends Dish {} | |
| val favoriteBreakfast: Person => Breakfast = { | |
| case John => Eggs | |
| case Mary => Coffee | |
| case Sam => Coffee | |
| } | |
| val favoritePerson: Person => Person = { | |
| case John => Mary | |
| case Mary => John | |
| case Sam => Mary | |
| } | |
| val servedIn: Breakfast => Dish = { | |
| case Eggs => Plate | |
| case Coffee => Mug | |
| case Oatmeal => Bowl | |
| case Toast => Plate | |
| } | |
| val favoritePersonsBreakfast = favoriteBreakfast compose favoritePerson | |
| val favoritePersonsBreakfastDish = servedIn compose favoriteBreakfast compose favoritePerson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment