Skip to content

Instantly share code, notes, and snippets.

@Jacoby6000
Created January 30, 2018 19:57
Show Gist options
  • Save Jacoby6000/3f28bbfd0f7480230a4ae6048dbd66a3 to your computer and use it in GitHub Desktop.
Save Jacoby6000/3f28bbfd0f7480230a4ae6048dbd66a3 to your computer and use it in GitHub Desktop.
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