Skip to content

Commit

Permalink
fixup! Redesign NonEmptyLazyList to be maximally lazy
Browse files Browse the repository at this point in the history
DummyImplicit
  • Loading branch information
NthPortal committed Sep 3, 2023
1 parent 06e1add commit 3a2df1c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ object NonEmptyLazyList extends NonEmptyLazyListInstances {

def #::[B >: A](elem: => B): NonEmptyLazyList[B] =
create(elem #:: ll)
def #:::[B >: A](prefix: => NonEmptyLazyList[B]): NonEmptyLazyList[B] =
create(prefix.toLazyList #::: ll)
def #:::[B >: A](prefix: => LazyList[B]): Maybe[B] =
new Maybe(() => prefix #::: ll)
def #:::[B >: A](prefix: => NonEmptyLazyList[B])(implicit d: DummyImplicit): NonEmptyLazyList[B] =
create(prefix.toLazyList #::: ll)
}

final class Deferrer[A] private[NonEmptyLazyList] (private val nell: () => NonEmptyLazyList[A]) extends AnyVal {
def #::[B >: A](elem: => B): NonEmptyLazyList[B] =
create(elem #:: nell().toLazyList)
def #:::[B >: A](prefix: => NonEmptyLazyList[B]): NonEmptyLazyList[B] =
create(prefix.toLazyList #::: nell().toLazyList)
def #:::[B >: A](prefix: => LazyList[B]): NonEmptyLazyList[B] =
create(prefix #::: nell().toLazyList)
def #:::[B >: A](prefix: => NonEmptyLazyList[B])(implicit d: DummyImplicit): NonEmptyLazyList[B] =
create(prefix.toLazyList #::: nell().toLazyList)
}

implicit def toDeferrer[A](nell: => NonEmptyLazyList[A]): Deferrer[A] =
Expand Down Expand Up @@ -187,7 +187,7 @@ class NonEmptyLazyListOps[A](private val value: NonEmptyLazyList[A])
/**
* Alias for `concatNell`
*/
final def ++[AA >: A](nell: => NonEmptyLazyList[AA]): NonEmptyLazyList[AA] =
final def ++[AA >: A](nell: => NonEmptyLazyList[AA])(implicit d: DummyImplicit): NonEmptyLazyList[AA] =
concatNell(nell)

/**
Expand All @@ -211,7 +211,7 @@ class NonEmptyLazyListOps[A](private val value: NonEmptyLazyList[A])
/**
* Alias for `appendNell`
*/
final def :++[AA >: A](nell: => NonEmptyLazyList[AA]): NonEmptyLazyList[AA] =
final def :++[AA >: A](nell: => NonEmptyLazyList[AA])(implicit d: DummyImplicit): NonEmptyLazyList[AA] =
appendNell(nell)

/**
Expand All @@ -235,7 +235,7 @@ class NonEmptyLazyListOps[A](private val value: NonEmptyLazyList[A])
/**
* Alias for `prependNell`
*/
final def ++:[AA >: A](nell: => NonEmptyLazyList[AA]): NonEmptyLazyList[AA] =
final def ++:[AA >: A](nell: => NonEmptyLazyList[AA])(implicit d: DummyImplicit): NonEmptyLazyList[AA] =
prependNell(nell)

/**
Expand Down

0 comments on commit 3a2df1c

Please sign in to comment.