Created
February 23, 2016 00:56
-
-
Save stanch/f5aa9223d47ac7577958 to your computer and use it in GitHub Desktop.
case class persistence visualized
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
case class Street(name: String, house: Int) | |
case class Address(street: Street, city: String) | |
case class Person(address: Address, age: Int) | |
val person1 = Person(Address(Street("Functional Rd.", 1), "London"), 35) | |
val person2 = person.modify(_.address.street.house).using(_ + 3) | |
/* | |
┌───────────┐ ┌───────────┐ | |
│Person (35)│ │Person (35)│ | |
└──────┬────┘ └──────┬────┘ | |
│ │ | |
v v | |
┌──────────┐ ┌──────────┐ | |
│Address ()│ │Address ()│ | |
└──┬────┬──┘ └───┬───┬──┘ | |
│ │ │ │ | |
│ └───┐ │ └─────┐ | |
v │ v │ | |
┌──────────┐ │ ┌──────────┐ │ | |
│Street (1)│ │ │Street (4)│ │ | |
└─────┬────┘ │ └─────┬────┘ │ | |
│ │ │ │ | |
│ └─────────┼────┐ │ | |
│ ┌──────────┘ │ │ | |
│ │ │ │ | |
v v v v | |
┌───────────────────────┐ ┌───────────────┐ | |
│String (Functional Rd.)│ │String (London)│ | |
└───────────────────────┘ └───────────────┘ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment