All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scala.meta.prettyprinters.Structure.scala Maven / Gradle / Ivy

Go to download

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