Skip to content

Instantly share code, notes, and snippets.

@dhinojosa
Created March 29, 2011 19:06
Show Gist options
  • Save dhinojosa/893021 to your computer and use it in GitHub Desktop.
Save dhinojosa/893021 to your computer and use it in GitHub Desktop.
Mucking with NonEmptyList discussing with friend
sealed trait NonEmptyList[+A] {
val head: A
val tail: List[A]
import Scalaz._
def <::[B >: A](b: B): NonEmptyList[B] = nel(b, head :: tail)
import collection.mutable.ListBuffer
def <:::[B >: A](bs: List[B]): NonEmptyList[B] = { //Scary
val b = new ListBuffer[B]
b ++= bs
b += head
b ++= tail
val bb = b.toList
nel(bb.head, bb.tail)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment