Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references of the NEL OneAnd alias #1563

Merged
merged 1 commit into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions core/src/main/scala/cats/data/OneAnd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import cats.instances.stream._
/**
* A data type which represents a single element (head) and some other
* structure (tail). As we have done in package.scala, this can be
* used to represent a List which is guaranteed to not be empty:
* used to represent a Stream which is guaranteed to not be empty:
*
* {{{
* type NonEmptyList[A] = OneAnd[List, A]
* type NonEmptyStream[A] = OneAnd[Stream, A]
* }}}
*/
final case class OneAnd[F[_], A](head: A, tail: F[A]) {

/**
* Combine the head and tail into a single `F[A]` value.
*/
def unwrap(implicit F: MonadCombine[F]): F[A] =
def unwrap(implicit F: Alternative[F]): F[A] =
F.combineK(F.pure(head), tail)

/**
Expand All @@ -33,7 +33,7 @@ final case class OneAnd[F[_], A](head: A, tail: F[A]) {
/**
* Append another OneAnd to this
*/
def combine(other: OneAnd[F, A])(implicit F: MonadCombine[F]): OneAnd[F, A] =
def combine(other: OneAnd[F, A])(implicit F: Alternative[F]): OneAnd[F, A] =
OneAnd(head, F.combineK(tail, F.combineK(F.pure(other.head), other.tail)))

/**
Expand Down Expand Up @@ -104,13 +104,13 @@ private[data] sealed trait OneAndInstances extends OneAndLowPriority2 {
implicit def catsDataShowForOneAnd[A, F[_]](implicit A: Show[A], FA: Show[F[A]]): Show[OneAnd[F, A]] =
Show.show[OneAnd[F, A]](_.show)

implicit def catsDataSemigroupKForOneAnd[F[_]: MonadCombine]: SemigroupK[OneAnd[F, ?]] =
implicit def catsDataSemigroupKForOneAnd[F[_]: Alternative]: SemigroupK[OneAnd[F, ?]] =
new SemigroupK[OneAnd[F, ?]] {
def combineK[A](a: OneAnd[F, A], b: OneAnd[F, A]): OneAnd[F, A] =
a combine b
}

implicit def catsDataSemigroupForOneAnd[F[_]: MonadCombine, A]: Semigroup[OneAnd[F, A]] =
implicit def catsDataSemigroupForOneAnd[F[_]: Alternative, A]: Semigroup[OneAnd[F, A]] =
catsDataSemigroupKForOneAnd[F].algebra

implicit def catsDataReducibleForOneAnd[F[_]](implicit F: Foldable[F]): Reducible[OneAnd[F, ?]] =
Expand Down
5 changes: 2 additions & 3 deletions docs/src/main/tut/datatypes/oneand.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ import cats.data.OneAnd
type NonEmptyList[A] = OneAnd[List, A]
```

which is the actual implementation of non-empty lists in cats. By
which used to be the implementation of non-empty lists in cats but has
been replaced by the `cats.data.NonEmptyList` data type. By
having the higher kinded type parameter `F[_]`, `OneAnd` is also able
to represent other "non-empty" data structures e.g.

```tut:silent
import cats.data.OneAnd

type NonEmptyStream[A] = OneAnd[Stream, A]
```