@@ -133,6 +133,37 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) extends NonEmptyCollec
133133 def prepend [AA >: A ](a : AA ): NonEmptyList [AA ] =
134134 NonEmptyList (a, head :: tail)
135135
136+ /**
137+ * Alias for [[prependList ]]
138+ *
139+ * {{{
140+ * scala> import cats.data.NonEmptyList
141+ * scala> val nel = NonEmptyList.of(1, 2, 3)
142+ * scala> val list = List(-1, 0)
143+ * scala> list ++: nel
144+ * res0: cats.data.NonEmptyList[Int] = NonEmptyList(-1, 0, 1, 2, 3)
145+ * }}}
146+ */
147+ def ++: [AA >: A ](other : List [AA ]): NonEmptyList [AA ] =
148+ prependList(other)
149+
150+ /**
151+ * Prepend another `List`
152+ *
153+ * {{{
154+ * scala> import cats.data.NonEmptyList
155+ * scala> val nel = NonEmptyList.of(1, 2, 3)
156+ * scala> val list = List(-1, 0)
157+ * scala> nel.prependList(list)
158+ * res0: cats.data.NonEmptyList[Int] = NonEmptyList(-1, 0, 1, 2, 3)
159+ * }}}
160+ */
161+ def prependList [AA >: A ](other : List [AA ]): NonEmptyList [AA ] =
162+ other match {
163+ case Nil => this
164+ case head :: tail => NonEmptyList (head, tail ::: toList)
165+ }
166+
136167 /**
137168 * Alias for append
138169 *
@@ -149,6 +180,19 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) extends NonEmptyCollec
149180 def append [AA >: A ](a : AA ): NonEmptyList [AA ] =
150181 NonEmptyList (head, tail :+ a)
151182
183+ /**
184+ * Alias for [[concat ]]
185+ *
186+ * {{{
187+ * scala> import cats.data.NonEmptyList
188+ * scala> val nel = NonEmptyList.of(1, 2, 3)
189+ * scala> nel.appendList(List(4, 5))
190+ * res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4, 5)
191+ * }}}
192+ */
193+ def appendList [AA >: A ](other : List [AA ]): NonEmptyList [AA ] =
194+ concat(other)
195+
152196 /**
153197 * Alias for concatNel
154198 *
0 commit comments