Class/Object

com.eharmony.aloha.util

ICList

Related Docs: object ICList | package util

Permalink

case class ICList[A](list: List[A]) extends Product with Serializable

A class that acts like an immutable list but allows disparate element types to be inserted as long as an implicit function from the input type to the list type exists in the implicit scope.

Typical usage will be like:

import java.io.InputStream
def getInputStream(i: Int) = new java.io.ByteArrayInputStream(i.toString.getBytes)

implicit val stringToInt = (_:String).toInt
implicit val isToInt = (is: InputStream) => stringToInt(io.Source.fromInputStream(is).getLines.mkString("\n"))

// Construct a list of Int from things we can convert to Ints from translation functions that are in scope.
// NOTICE: Because of implicitConversionListToList, we get implicit conversion to lists.
val lst: List[Int] = (1 :: getInputStream(2) :: "3" :: ICList.empty[Int])

require(lst.isInstanceOf[List[Int]] && (1 to 3) == lst, "lst should be List(1,2,3)")

Note: We use implicit functions rather than view bounds because of conflicts with method conforms in object Predef of type [A]=> <:<[A,A] for certain types.

A

the list type

list

a contained list backing the ICList.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ICList
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ICList(list: List[A])

    Permalink

    list

    a contained list backing the ICList.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ::[B](b: B)(implicit f: (B) ⇒ A): ICList[A]

    Permalink

    Construct a new ICList with f(b) prepended.

    Construct a new ICList with f(b) prepended.

    B

    the input type to convert to type A

    b

    a value to prepend to the ICList

    f

    a function to convert the input to a value of type A

    returns

    a new ICList of type A with f(b) prepended.

  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. def append(a: A): ICList[A]

    Permalink

    Construct a new ICList with a appended.

    Construct a new ICList with a appended.

    a

    a value to append to the ICList

    returns

    a new ICList of type A with a appended.

  6. def append[B](b: B)(implicit f: (B) ⇒ A): ICList[A]

    Permalink

    Construct a new ICList with f(b) appended.

    Construct a new ICList with f(b) appended.

    B

    the input type to convert to type A

    b

    a value to append to the ICList

    f

    a function to convert the input to a value of type A

    returns

    a new ICList of type A with f(b) appended.

  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. val list: List[A]

    Permalink

    a contained list backing the ICList.

  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. def prepend(a: A): ICList[A]

    Permalink

    Construct a new ICList with a prepended.

    Construct a new ICList with a prepended.

    a

    a value to prepend to the ICList

    returns

    a new ICList of type A with a prepended.

  18. def prepend[B](b: B)(implicit f: (B) ⇒ A): ICList[A]

    Permalink

    Construct a new ICList with f(b) prepended.

    Construct a new ICList with f(b) prepended.

    B

    the input type to convert to type A

    b

    a value to prepend to the ICList

    f

    a function to convert the input to a value of type A

    returns

    a new ICList of type A with f(b) prepended.

  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  20. def toList: List[A]

    Permalink

    Explicitly convert to a list.

  21. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped