Val

object Val

Value Container Framework

Read more in the Guide.

Val is fully exported to scalqa root, thus all members of Val can be called with or without "Val." prefix.

For example:

val v:  Val.Stream[Int]  = ???
// is same as
val v: Stream[Int]       = ???
Source
__.scala
class java.lang.Object
trait scala.Matchable
class Any

Member

abstract class Buffer[A] extends Idx.M[A] with Able.Contain[A]

Value Buffer

Buffer is the default implementation of Mutable Indexed Collection

Buffer is an abstract class with concrete implementations: AnyRef.G.Buffer, Byte.G.Buffer, Int.G.Buffer, etc.

Source
__.scala
abstract class Buffer[A] extends Idx.M[A] with Able.Contain[A]

Value Buffer

Buffer is the default implementation of Mutable Indexed Collection

Buffer is an abstract class with concrete implementations: AnyRef.G.Buffer, Byte.G.Buffer, Int.G.Buffer, etc.

Source
__.scala
trait Collection[+A] extends Able.Stream[A] with Able.Size

Value Collection

Collection is the root of collections framework

There are 3 main subtypes:

  • Idx - values can be accessed by Int index
  • Lookup - values can be accessed by key lookup
  • Set - collection of unique values
Source
__.scala
trait Collection[+A] extends Able.Stream[A] with Able.Size

Value Collection

Collection is the root of collections framework

There are 3 main subtypes:

  • Idx - values can be accessed by Int index
  • Lookup - values can be accessed by key lookup
  • Set - collection of unique values
Source
__.scala
trait Idx[+A] extends Collection[A]

Indexed Collection

Elements in Idx can be efficiently accessed with Int index starting from 0

The immutable implementation of Idx is Pack

Source
__.scala
trait Idx[+A] extends Collection[A]

Indexed Collection

Elements in Idx can be efficiently accessed with Int index starting from 0

The immutable implementation of Idx is Pack

Source
__.scala
trait Lookup[A, +B] extends Collection[B]

Lookup Collection

In Lookup collection every element is stored with a 'key' and can be accessed (looked up) with this 'key'

It is a greatly simplified equivalent of scala.Map

Source
__.scala
trait Lookup[A, +B] extends Collection[B]

Lookup Collection

In Lookup collection every element is stored with a 'key' and can be accessed (looked up) with this 'key'

It is a greatly simplified equivalent of scala.Map

Source
__.scala
opaque type Opt[+A]

Value Option

Opt is a container, which can hold a single value or be empty

Option can be converted to value with method or, which also takes default value for the case when option is empty

Option is often used as Boolean, where ''Option'' with value is converted to 'true' and empty option is converted to 'false'

val l: Lookup[Int,String] = ???

val o: Opt[String] = l.getOpt(12)

if(o) println("Value found.")
else  println("Value not found.")
Source
__.scala
abstract class Pack[A] extends Idx[A]

Value Pack

Pack is the most ubiquitous immutable collection, like List in Scala

Unlike List, Pack is mostly backed by an Array and can be specialized. It usually has smaller memory footprint and in most cases is faster to manipulate data.

Source
__.scala
abstract class Pack[A] extends Idx[A]

Value Pack

Pack is the most ubiquitous immutable collection, like List in Scala

Unlike List, Pack is mostly backed by an Array and can be specialized. It usually has smaller memory footprint and in most cases is faster to manipulate data.

Source
__.scala
trait Pro[+A]

Value Provider

Whenever value provider belongs to an object, it effectively becomes a property holder for this object.

Properties Framework

There are 4 types of standard properties:

The inheritance graph looks like:

       Pro.O
      /      \
   Pro        Pro.OM
      \     /
       Pro.M

Here is an example of 'name' property definition hierarchy:

        trait Foo:                                     // 'name' is read only
          def namePro          : Pro[String]
          def name             : String = namePro()    // required shortcut

        trait Foo_M extends Foo:                       // 'name' is read/write
          def namePro          : Pro.M[String]
          def name_=(v:String) : Unit = namePro() = v  // required shortcut

        trait Foo_O extends Foo:                       // 'name' is read/listenTo
          def namePro          : Pro.O[String]

        trait Foo_OM extends Foo_O with Foo_M:         // 'name' is read/write/listenTo
          def namePro          : Pro.OM[String]

Note. The 'required shortcuts' must be implemented. They will not even show up in documentation, because they are assumed to be there

Source
__.scala
trait Pro[+A]

Value Provider

Whenever value provider belongs to an object, it effectively becomes a property holder for this object.

Properties Framework

There are 4 types of standard properties:

The inheritance graph looks like:

       Pro.O
      /      \
   Pro        Pro.OM
      \     /
       Pro.M

Here is an example of 'name' property definition hierarchy:

        trait Foo:                                     // 'name' is read only
          def namePro          : Pro[String]
          def name             : String = namePro()    // required shortcut

        trait Foo_M extends Foo:                       // 'name' is read/write
          def namePro          : Pro.M[String]
          def name_=(v:String) : Unit = namePro() = v  // required shortcut

        trait Foo_O extends Foo:                       // 'name' is read/listenTo
          def namePro          : Pro.O[String]

        trait Foo_OM extends Foo_O with Foo_M:         // 'name' is read/write/listenTo
          def namePro          : Pro.OM[String]

Note. The 'required shortcuts' must be implemented. They will not even show up in documentation, because they are assumed to be there

Source
__.scala
trait Promise[+A]

Value Promise

Promise represents value which will be available later (at some point of time), but it can now be incorporated in current calculations

val s: String = "Hello"

val v: Promise[String] = Promise(s + " Concurrent Promise!")

v.resultOpt.tp    // Value is likely not available yet

v.onResult(_.tp) // Will run when value is available

// Output
Opt(VOID)
Result(Hello Concurrent Promise!)
Source
__.scala
trait Promise[+A]

Value Promise

Promise represents value which will be available later (at some point of time), but it can now be incorporated in current calculations

val s: String = "Hello"

val v: Promise[String] = Promise(s + " Concurrent Promise!")

v.resultOpt.tp    // Value is likely not available yet

v.onResult(_.tp) // Will run when value is available

// Output
Opt(VOID)
Result(Hello Concurrent Promise!)
Source
__.scala
abstract class Range[A] extends Able.Contain[A] with Able.Empty

Value Range

Range is logically defined with the following defs:

  • start
  • end,
  • and ordering, which makes the above meaningful

Range has a notion that an element can be within the range, i.e. between start and end, or outside

Note. Scala provided range structures (scala.collection.immutable.Range and scala.collection.immutable.NumericRange) are implemented more as collections and this class is designed to close this void focusing on basic range features.

Source
__.scala
abstract class Range[A] extends Able.Contain[A] with Able.Empty

Value Range

Range is logically defined with the following defs:

  • start
  • end,
  • and ordering, which makes the above meaningful

Range has a notion that an element can be within the range, i.e. between start and end, or outside

Note. Scala provided range structures (scala.collection.immutable.Range and scala.collection.immutable.NumericRange) are implemented more as collections and this class is designed to close this void focusing on basic range features.

Source
__.scala
opaque type Result[+A]

Value Result

Result is a container, which holds either 'value' or 'problem', which explains why value is not available.

Unlike Opt, Result is never void, even if there is no value, then, there must be a problem.

val r1: Result[Int] = "123".toIntResult

r1.tp   // Prints Result(123)

val r2: Result[Int] = "ABC".toIntResult

r2.tp   // Prints Result(Problem(For input string: "ABC"))
Source
__.scala
abstract class Set[A] extends Collection[A] with Able.Contain[A]

Set is an immutable collection with no duplicate values

When an element is joined to a Set, it is evaluated for uniqueness and the operation is ignored in case of duplicates.

Note: Set is a concrete single implementation of unique collection. There is no general "Set" interface, because its use is rare. If there is a need for more efficient "Set" functionality, create one with Collection.Mutable.noDuplicates. The result is faster, but is not thread safe.

Source
__.scala
abstract class Set[A] extends Collection[A] with Able.Contain[A]

Set is an immutable collection with no duplicate values

When an element is joined to a Set, it is evaluated for uniqueness and the operation is ignored in case of duplicates.

Note: Set is a concrete single implementation of unique collection. There is no general "Set" interface, because its use is rare. If there is a need for more efficient "Set" functionality, create one with Collection.Mutable.noDuplicates. The result is faster, but is not thread safe.

Source
__.scala
trait Stream[+A]

Value Stream

Read about Stream in the Guide.

Stream has just one method to be implemented, but it has large attached libraries for:

Source
__.scala
trait Stream[+A]

Value Stream

Read about Stream in the Guide.

Stream has just one method to be implemented, but it has large attached libraries for:

Source
__.scala