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

special.wrappers.WrappersSpec.scala Maven / Gradle / Ivy

The newest version!
package special.wrappers

import sigma.data.RType

/** Base class for wrappers of such types as WOption, WRType etc.
  * Used in graph IR to implement method invocation.
  */
trait WrapSpecBase extends WrapSpec {
}

/** Wrappers spec for Option */
class OptionWrapSpec extends WrapSpecBase {
  def get[A](xs: Option[A]): A = xs.get
  def getOrElse[A](xs: Option[A], default: => A): A = xs.getOrElse(default)
  def map[A,B](xs: Option[A], f: A => B): Option[B] = xs.map(f)
  def filter[A](xs: Option[A], f: A => Boolean): Option[A] = xs.filter(f)
  def isDefined[A](xs: Option[A]): Boolean  = xs.isDefined
};

/** Wrappers spec for RType */
class RTypeWrapSpec extends WrapSpecBase {
  def name[T](d: RType[T]): String = d.name
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy