com.eharmony.aloha.util

ICList

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
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

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

    list

    a contained list backing the ICList.

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    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.

  5. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  6. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  7. def append(a: A): ICList[A]

    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.

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

    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.

  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def clone(): AnyRef

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

    Definition Classes
    AnyRef
  12. def finalize(): Unit

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

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

    Definition Classes
    Any
  15. val list: List[A]

    a contained list backing the ICList.

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

    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

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

    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.

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

    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.

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

    Definition Classes
    AnyRef
  22. def toList: List[A]

    Explicitly convert to a list.

    Explicitly convert to a list.

    returns

  23. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped