Packages

p

com.daml.scalautil

nonempty

package nonempty

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. nonempty
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type NonEmpty[+A] = nonempty.NonEmptyColl.NonEmpty[A]

    A non-empty A.

    A non-empty A. Implicitly converts to A in relevant contexts.

    Why use this instead of scalaz.OneAnd?

    OneAnd is constructively non-empty; there is no way to "cheat". However, its focus on functorial use cases means that it is well-suited for uninterpreted sequences like List and Vector, but less so those where parts of the elements have some semantics, such as with Map and Set. For cases like Set you also have to do some extra work to make sure the head doesn't break the invariant of the underlying structure.

    By contrast, NonEmpty is nominally non-empty. We take care to define only those primitives that will preserve non-emptiness, but it is possible to make a mistake (for example, if you added flatMap but wrote the wrong signature). The benefits are that you get to treat them more like the underlying structure, because there is no structural difference, and operations on existing code will more transparently continue to work (and preserve the non-empty property where reasonable) than the equivalent port to use OneAnd.

    Using this library sensibly with Scala 2.12 requires -Xsource:2.13 and -Ypartial-unification.

  2. sealed abstract class NonEmptyColl extends AnyRef

    The visible interface of NonEmpty; use that value to access these members.

  3. sealed abstract class NonEmptyCollInstances extends AnyRef
  4. type NonEmptyF[F[_], A] = nonempty.NonEmptyColl.NonEmptyF[F, A]

    A subtype of NonEmpty[F[A]] where A is in position to be inferred properly.

    A subtype of NonEmpty[F[A]] where A is in position to be inferred properly. When attempting to fit a type to the type params C[T], scalac will infer the following:

    type shape | C | T ----------------+----------------+----- NonEmpty[F[A]] | NonEmpty | F[A] NonEmptyF[F, A] | NonEmpty[F, *] | A

    If you want to traverse or foldLeft or map on A, the latter is far more convenient. So any value whose type is the former can be converted to the latter via the toF method.

    In fact, given any NonEmpty[Foo] where Foo can be matched to type parameters C[T], toF will infer a NonEmptyF[C, T] for whatever values of C and T scalac chooses. For example, if bar: NonEmpty[Map[K, V]], then bar.toF: NonEmptyF[Map[K, *], V], because that's how scalac destructures that type.

Value Members

  1. val :∓: :-+.type
  2. val NonEmpty: NonEmptyColl
  3. val ±:: +-:.type
  4. object +-:

    Total version of +:.

  5. object :-+

    Total version of :+.

  6. object NonEmptyColl extends NonEmptyCollInstances

    If you ever have to import NonEmptyColl or anything from it, your Scala settings are probably wrong.

  7. object NonEmptyReturningOps

    Functions where the receiver is non-empty can be found implicitly with no further imports; they "just work".

    Functions where the receiver is non-empty can be found implicitly with no further imports; they "just work". However, if we wish to refine a method on a built-in type that merely returns a nonempty-annotated type, we must import the contents of this object.

Inherited from AnyRef

Inherited from Any

Ungrouped