scala.meta.prettyprinters.Structure.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common_2.11 Show documentation
Show all versions of common_2.11 Show documentation
Bag of private and public helpers used in scala.meta's APIs and implementations
The newest version!
package scala.meta
package prettyprinters
import scala.annotation.implicitNotFound
@implicitNotFound(msg = "don't know how to show[Structure] for ${T}")
trait Structure[-T] extends Show[T]
object Structure {
import Show.{repeat => r, sequence => _, _}
def apply[T](f: T => Show.Result): Structure[T] = new Structure[T] {
def apply(input: T) = f(input)
}
implicit def structureList[T: Structure]: Structure[List[T]] = Structure { xs =>
Sequence(Str("List("), r(xs.map(x => implicitly[Structure[T]].apply(x)), ", "), Str(")"))
}
implicit def structureOption[T: Structure]: Structure[Option[T]] = Structure {
case scala.Some(x) => Sequence(Str("Some("), implicitly[Structure[T]].apply(x), Str(")"))
case scala.None => Str("None")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy