special.wrappers.WrappersSpec.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sigma-state_2.12 Show documentation
Show all versions of sigma-state_2.12 Show documentation
Interpreter of a Sigma-State language
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