Skip to content

Commit

Permalink
typelevel#804 - encoding for Set derivatives as well - test build
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-twiner committed Mar 20, 2024
1 parent fb1c109 commit ae8b69a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions dataset/src/main/scala/frameless/TypedEncoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import shapeless._
import shapeless.ops.hlist.IsHCons

import scala.collection.generic.CanBuildFrom
import scala.collection.immutable.TreeSet
import scala.collection.immutable.HashSet.HashTrieSet
import scala.collection.immutable.{ListSet, TreeSet}

abstract class TypedEncoder[T](
implicit
Expand Down Expand Up @@ -497,7 +498,7 @@ object TypedEncoder {
/**
* Per #804 - when MapObjects is used in interpreted mode the type returned is Seq, not the derived type used in compilation
*
* This type class offers extensible conversion for more specific types. By default Seq, List and Vector are supported.
* This type class offers extensible conversion for more specific types. By default Seq, List and Vector for Seq's and Set, TreeSet and HashTrieSet are supported.
*
* @tparam C
*/
Expand All @@ -521,6 +522,12 @@ object TypedEncoder {
implicit def setToTreeSet[Y](implicit cbf: CanBuildFrom[Nothing, Y, TreeSet[Y]]) = new CollectionConversion[Set, TreeSet, Y] {
override def convert(c: Set[Y]): TreeSet[Y] = c.to[TreeSet]
}
implicit def setToListSet[Y](implicit cbf: CanBuildFrom[Nothing, Y, ListSet[Y]]) = new CollectionConversion[Set, ListSet, Y] {
override def convert(c: Set[Y]): ListSet[Y] = c.to[ListSet]
}
implicit def setToTrieSet[Y](implicit cbf: CanBuildFrom[Nothing, Y, HashTrieSet[Y]]) = new CollectionConversion[Set, HashTrieSet, Y] {
override def convert(c: Set[Y]): HashTrieSet[Y] = c.to[HashTrieSet]
}
}

implicit def seqEncoder[C[X] <: Seq[X], T](
Expand Down

0 comments on commit ae8b69a

Please sign in to comment.