Created
July 24, 2018 09:05
-
-
Save asflierl/7da0a53ce65fc9ca7a1e90a138fad2e2 to your computer and use it in GitHub Desktop.
just another day in Scala...
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
private type H[A <: BSONValue, B] = BSONHandler[A, B] | |
private type DH[A] = BSONDocumentHandler[A] | |
object Implicits extends BSONConverter with DaoToDocDerivation { | |
private implicit def `(A, B) <-> BSON`[A <: BSONValue, B, C <: BSONValue, D](implicit hab: H[A, B], hcd: H[C, D]): DH[(B, D)] = handler[Tuple2[B, D]] | |
private implicit def `Coll[A] <-> BSON`[A[_], B](implicit h: H[_ <: BSONValue, B], cbf: CanBuildFrom[A[_], B, A[B]], ev: A[B] <:< Traversable[B]): H[BSONArray, A[B]] = | |
BSONHandler(bsonArrayToCollectionReader[A, B].read, collectionToBSONArrayCollectionWriter[B, A[B]].write) | |
private implicit def `Map[A, B] <-> BSON`[A, B](implicit htab: DH[(A, B)]): H[BSONArray, Map[A, B]] = | |
`Coll[A] <-> BSON`[Vector, (A, B)].as(_.toMap, _.toVector) | |
private implicit def `Set[A] <-> BSON`[A](implicit htab: H[_ <: BSONValue, A]): H[BSONArray, Set[A]] = | |
`Coll[A] <-> BSON`[Set, A] | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment