_view

opaque type _view[+A]

Self View Methods

Self view is another library available on all types, but it has to be activated by calling a universal ".^" or (".self_^") method on original value.

Due to opaque implementation, calling "self view" methods incures no overhead as if they were called directly on base value.

For example:

 val pack: ><[String] = "FOO".^.><

A common use case is to manipulate an object within expression context:

 val a : Array[String] = new Array[String](2).^(_(0)="A").^(_(1)="B")

because all calls are inlined, the above expression is equivalent to:

 val a : Array[String] = new Array[String](2)
 a(0)="A"
 a(1)="B"
Source
_view.scala

Def

@scala.annotation.targetName("pack")
inline def ><[A]: ><[A]

Pack

Pack

Creates a pack with this sigle value

Source
_view.scala
@scala.annotation.targetName("nonEmptyOpt")
inline def ?[A](using inline e: Given.EmptyTag[A], inline d: Given.VoidTag[A]): Opt[A]

As option

As option

Returns base value as an option.

Unlike general .? method, this method will create empty option for void or empty values

 List().?.tp    // prints: Opt(List())

 List().^.?.tp  // prints: Opt(\/)

Source
_view.scala
inline def apply[A](inline f: A => U): A

Process

Process

Processes value with given function

Returns the base value itself

 val a : Array[String] = new Array[String](2).^(a => { a(0)="A"; a(1)="B" })
Source
_view.scala
inline def as[A](inline f: A => B): B

Convert

Convert

Converts base value with given function

Returns the result of conversion

Source
_view.scala
def hash[A]: String

Hash code

Hash code

Returns alphanumeric hash code 4 characters long

It is shorter and display friendly compared to Java hash.

Source
_view.scala
def id[A](using d: Given.TypeTag[A]): String

Instance id

Instance id

Usually it is type name and hash code.

Source
_view.scala
inline def isEmpty[A](using inline d: Given.EmptyTag[A]): Boolean

Empty check

Empty check

Returns true if value is empty, false - otherwise

Source
_view.scala
inline def isVoid[A](using inline d: Given.VoidTag[A]): Boolean

Void check

Void check

Returns true if value is void, false - otherwise

Source
_view.scala
inline def nonEmpty[A](using inline d: Given.EmptyTag[A]): Boolean

Non empty check

Non empty check

Returns true if value is not empty, false - otherwise

Source
_view.scala
inline def nonVoid[A](using inline d: Given.VoidTag[A]): Boolean

Non void check

Non void check

Returns true if value is not void, false - otherwise

Source
_view.scala
inline def revise[A](inline f: A => A): A

Change value

Change value

Changes base value with the given function

Returns the new value

Note. Similar to as conversion, but the value type stays the same

Source
_view.scala
inline def reviseIf[A](inline filter: A => Boolean, inline f: A => A): A

Conditionally change value

Conditionally change value

Changes base value with the given function, if condition is right

Returns new value or old value

Source
_view.scala
def typeName[A](using d: Given.TypeTag[A]): String

Type name

Type name

Returns type name, which is class name for reference types and given tagged name for raw types

Source
_view.scala

Given