Created
January 30, 2018 19:57
-
-
Save Jacoby6000/3f28bbfd0f7480230a4ae6048dbd66a3 to your computer and use it in GitHub Desktop.
This file contains 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 Foo(a: Int, b: String, c: Bar) | |
case class Bar(x: Int, y: Baz) | |
case class Baz(z: String) | |
// Each case class can be generalized in to a product, where that product is just the parts of the case class | |
// Foo === Int :: String :: Bar :: HNil | |
// Bar === Int :: Baz :: HNil | |
// Baz === String :: HNil | |
// doobie then flattens the structure, so | |
// `Bar` is substituted with Int :: Baz :: HNil, | |
// and `Baz` is substituted with `String :: HNil`. | |
// So, a Foo is really `Int :: String :: Int :: String :: HNil`. | |
// Doobie will derive a composite instance from this and use the position for the mappings. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment