Class/Object

cats.data

NonEmptyList

Related Docs: object NonEmptyList | package data

Permalink

final case class NonEmptyList[+A](head: A, tail: List[A]) extends Product with Serializable

A data type which represents a non empty list of A, with single element (head) and optional structure (tail).

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. NonEmptyList
  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 NonEmptyList(head: A, tail: List[A])

    Permalink

Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ++[AA >: A](l: List[AA]): NonEmptyList[AA]

    Permalink
  4. def :+[AA >: A](a: AA): NonEmptyList[AA]

    Permalink

    Alias for append

    Alias for append

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3)
    scala> nel :+ 4
    res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4)
  5. def ::[AA >: A](a: AA): NonEmptyList[AA]

    Permalink
  6. def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA]

    Permalink

    Alias for concatNel

    Alias for concatNel

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3)
    scala> nel ::: NonEmptyList.of(4, 5)
    res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4, 5)
  7. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def ===[AA >: A](o: NonEmptyList[AA])(implicit AA: Eq[AA]): Boolean

    Permalink
  9. def append[AA >: A](a: AA): NonEmptyList[AA]

    Permalink
  10. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def coflatMap[B](f: (NonEmptyList[A]) ⇒ B): NonEmptyList[B]

    Permalink
  13. def collect[B](pf: PartialFunction[A, B]): List[B]

    Permalink

    Builds a new List by applying a partial function to all the elements from this NonEmptyList on which the function is defined

    Builds a new List by applying a partial function to all the elements from this NonEmptyList on which the function is defined

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5)
    scala> nel.collect { case v if v < 3 => v }
    res0: scala.collection.immutable.List[Int] = List(1, 2)
    scala> nel.collect {
         |  case v if v % 2 == 0 => "even"
         |  case _ => "odd"
         | }
    res1: scala.collection.immutable.List[String] = List(odd, even, odd, even, odd)
  14. def concat[AA >: A](other: List[AA]): NonEmptyList[AA]

    Permalink
  15. def concatNel[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA]

    Permalink

    Append another NonEmptyList

  16. def distinct[AA >: A](implicit O: Order[AA]): NonEmptyList[AA]

    Permalink

    Remove duplicates.

    Remove duplicates. Duplicates are checked using Order[_] instance.

  17. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. def exists(p: (A) ⇒ Boolean): Boolean

    Permalink

    Check whether at least one element satisfies the predicate

  19. def filter(p: (A) ⇒ Boolean): List[A]

    Permalink

    Remove elements not matching the predicate

    Remove elements not matching the predicate

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5)
    scala> nel.filter(_ < 3)
    res0: scala.collection.immutable.List[Int] = List(1, 2)
  20. def filterNot(p: (A) ⇒ Boolean): List[A]

    Permalink

    Remove elements matching the predicate

    Remove elements matching the predicate

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5)
    scala> nel.filterNot(_ < 3)
    res0: scala.collection.immutable.List[Int] = List(3, 4, 5)
  21. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. def find(p: (A) ⇒ Boolean): Option[A]

    Permalink

    Find the first element matching the predicate, if one exists

  23. def flatMap[B](f: (A) ⇒ NonEmptyList[B]): NonEmptyList[B]

    Permalink
  24. def foldLeft[B](b: B)(f: (B, A) ⇒ B): B

    Permalink

    Left-associative fold on the structure using f.

  25. def foldRight[B](lb: Eval[B])(f: (A, Eval[B]) ⇒ Eval[B]): Eval[B]

    Permalink

    Right-associative fold on the structure using f.

  26. def forall(p: (A) ⇒ Boolean): Boolean

    Permalink

    Check whether all elements satisfy the predicate

  27. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  28. def groupBy[B](f: (A) ⇒ B)(implicit B: Order[B]): SortedMap[B, NonEmptyList[A]]

    Permalink

    Groups elements inside this NonEmptyList according to the Order of the keys produced by the given mapping function.

    Groups elements inside this NonEmptyList according to the Order of the keys produced by the given mapping function.

    scala> import scala.collection.immutable.SortedMap
    scala> import cats.data.NonEmptyList
    scala> import cats.instances.boolean._
    scala> val nel = NonEmptyList.of(12, -2, 3, -5)
    scala> nel.groupBy(_ >= 0)
    res0: SortedMap[Boolean, cats.data.NonEmptyList[Int]] = Map(false -> NonEmptyList(-2, -5), true -> NonEmptyList(12, 3))
  29. def groupByNem[B](f: (A) ⇒ B)(implicit B: Order[B]): NonEmptyMap[B, NonEmptyList[A]]

    Permalink

    Groups elements inside this NonEmptyList according to the Order of the keys produced by the given mapping function.

    Groups elements inside this NonEmptyList according to the Order of the keys produced by the given mapping function.

    scala> import cats.data._
    scala> import cats.instances.boolean._
    scala> val nel = NonEmptyList.of(12, -2, 3, -5)
    scala> nel.groupByNem(_ >= 0)
    res0: NonEmptyMap[Boolean, NonEmptyList[Int]] = Map(false -> NonEmptyList(-2, -5), true -> NonEmptyList(12, 3))
  30. val head: A

    Permalink
  31. def init: List[A]

    Permalink

    Selects all elements except the last

    Selects all elements except the last

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5)
    scala> nel.init
    res0: scala.collection.immutable.List[Int] = List(1, 2, 3, 4)
  32. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  33. def last: A

    Permalink

    Selects the last element

    Selects the last element

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5)
    scala> nel.last
    res0: Int = 5
  34. def length: Int

    Permalink
  35. def map[B](f: (A) ⇒ B): NonEmptyList[B]

    Permalink

    Applies f to all the elements of the structure

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

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

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

    Permalink
    Definition Classes
    AnyRef
  39. def prepend[AA >: A](a: AA): NonEmptyList[AA]

    Permalink
  40. def reduce[AA >: A](implicit S: Semigroup[AA]): AA

    Permalink

    Reduce using the Semigroup of AA.

  41. def reduceLeft[AA >: A](f: (AA, AA) ⇒ AA): AA

    Permalink

    Left-associative reduce using f.

  42. def reverse: NonEmptyList[A]

    Permalink

    Reverse this NonEmptyList.

    Reverse this NonEmptyList.

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3)
    scala> nel.reverse
    res0: cats.data.NonEmptyList[Int] = NonEmptyList(3, 2, 1)
  43. def show[AA >: A](implicit AA: Show[AA]): String

    Permalink
  44. def size: Int

    Permalink

    The size of this NonEmptyList

    The size of this NonEmptyList

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5)
    scala> nel.size
    res0: Int = 5
  45. def sortBy[B](f: (A) ⇒ B)(implicit B: Order[B]): NonEmptyList[A]

    Permalink

    Sorts this NonEmptyList according to an Order on transformed B from A

    Sorts this NonEmptyList according to an Order on transformed B from A

    scala> import cats.data.NonEmptyList
    scala> import cats.instances.int._
    scala> val nel = NonEmptyList.of(('a', 4), ('z', 1), ('e', 22))
    scala> nel.sortBy(_._2)
    res0: cats.data.NonEmptyList[(Char, Int)] = NonEmptyList((z,1), (a,4), (e,22))
  46. def sorted[AA >: A](implicit AA: Order[AA]): NonEmptyList[AA]

    Permalink

    Sorts this NonEmptyList according to an Order

    Sorts this NonEmptyList according to an Order

    scala> import cats.data.NonEmptyList
    scala> import cats.instances.int._
    scala> val nel = NonEmptyList.of(12, 4, 3, 9)
    scala> nel.sorted
    res0: cats.data.NonEmptyList[Int] = NonEmptyList(3, 4, 9, 12)
  47. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  48. val tail: List[A]

    Permalink
  49. def toList: List[A]

    Permalink

    Return the head and tail into a single list

    Return the head and tail into a single list

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of(1, 2, 3, 4, 5)
    scala> nel.toList
    res0: scala.collection.immutable.List[Int] = List(1, 2, 3, 4, 5)
  50. def toNem[T, U](implicit ev: <:<[A, (T, U)], order: Order[T]): NonEmptyMap[T, U]

    Permalink

    Creates new NonEmptyMap, similarly to List#toMap from scala standard library.

    Creates new NonEmptyMap, similarly to List#toMap from scala standard library.

    scala> import cats.data._
    scala> import cats.instances.int._
    scala> val nel = NonEmptyList((0, "a"), List((1, "b"),(0, "c"), (2, "d")))
    scala> nel.toNem
    res0: NonEmptyMap[Int,String] = Map(0 -> c, 1 -> b, 2 -> d)
  51. def toNes[B >: A](implicit order: Order[B]): NonEmptySet[B]

    Permalink

    Creates new NonEmptySet, similarly to List#toSet from scala standard library.

    Creates new NonEmptySet, similarly to List#toSet from scala standard library.

    scala> import cats.data._
    scala> import cats.instances.int._
    scala> val nel = NonEmptyList(1, List(2,2,3,4))
    scala> nel.toNes
    res0: cats.data.NonEmptySet[Int] = TreeSet(1, 2, 3, 4)
  52. def toString(): String

    Permalink
    Definition Classes
    NonEmptyList → AnyRef → Any
  53. def traverse[G[_], B](f: (A) ⇒ G[B])(implicit G: Applicative[G]): G[NonEmptyList[B]]

    Permalink
  54. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. def zipWith[B, C](b: NonEmptyList[B])(f: (A, B) ⇒ C): NonEmptyList[C]

    Permalink

    Zips this NonEmptyList with another NonEmptyList and applies a function for each pair of elements.

    Zips this NonEmptyList with another NonEmptyList and applies a function for each pair of elements.

    scala> import cats.data.NonEmptyList
    scala> val as = NonEmptyList.of(1, 2, 3)
    scala> val bs = NonEmptyList.of("A", "B", "C")
    scala> as.zipWith(bs)(_ + _)
    res0: cats.data.NonEmptyList[String] = NonEmptyList(1A, 2B, 3C)
  58. def zipWithIndex: NonEmptyList[(A, Int)]

    Permalink

    Zips each element of this NonEmptyList with its index.

    Zips each element of this NonEmptyList with its index.

    scala> import cats.data.NonEmptyList
    scala> val nel = NonEmptyList.of("a", "b", "c")
    scala> nel.zipWithIndex
    res0: cats.data.NonEmptyList[(String, Int)] = NonEmptyList((a,0), (b,1), (c,2))

Deprecated Value Members

  1. def concat[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 1.0.0-RC1) Use concatNel

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped