<commit_before>package com.equalinformation.fpps.week4

/**
 * Created by bpupadhyaya on 9/30/15.
 */
trait ListVariance[+T] { // Co-variant
  def isEmpty: Boolean
  def head: T
  def tail: ListVariance[T]
}

class Cons[T](val head: T, val tail: ListVariance[T]) extends ListVariance[T] {
  def isEmpty = false
}

object Nil extends ListVariance[Nothing] {
  def isEmpty = true
  def head: Nothing = throw new NoSuchElementException("Nil.head")
  def tail: Nothing = throw new NoSuchElementException("Nil.tail")
}

object test {
  val x: ListVariance[String] = Nil
}<commit_msg>Implement prepend in a list.<commit_after>package com.equalinformation.fpps.week4


/**
 * Created by bpupadhyaya on 9/30/15.
 */
trait ListVariance[+T] { // Co-variant
  def isEmpty: Boolean
  def head: T
  def tail: ListVariance[T]
  def prepend[U >: T] (elem: U): ListVariance[U] = new Cons(elem, this)
}

class Cons[T](val head: T, val tail: ListVariance[T]) extends ListVariance[T] {
  def isEmpty = false
}

object Nil extends ListVariance[Nothing] {
  def isEmpty = true
  def head: Nothing = throw new NoSuchElementException("Nil.head")
  def tail: Nothing = throw new NoSuchElementException("Nil.tail")
}

object test {
  val x: ListVariance[String] = Nil
  // def f(xs: ListVariance[NonEmpty], x: Empty) = xs prepend x
}
{'fraction_non_alphanumeric': 0.12155963302752294, 'fraction_numerical': 0.009174311926605505, 'mean_word_length': 4.278225806451613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4823682', 'n_tokens_mistral': 467, 'n_tokens_neox': 451, 'n_words': 133}