<commit_before>import scalaz._
import spire.algebra.{Monoid => _, _}
import spire.implicits._
import spire.math.Interval
import spire.math.interval.{Bound,ValueBound}

package object cilib {

//  val ::  = ICons
//  val Nil = INil

  // Should expand into a typeclass? Getter?
  type Selection[A] = (List[A], A) => List[A]
  type Crossover[A] = NonEmptyList[Position[A]] => Step[A,NonEmptyList[Position[A]]]

  type Distance[F[_],A] = (F[A], F[A]) => A

  def positive(d: Double): Maybe[Double @@ Tags.Positive] =
    if (d > 0.0) Tag.subst(Maybe.just(d))
    else Maybe.empty

  def negative(d: Double): Maybe[Double @@ Tags.Negative] =
    if (d < 0.0) Tag.subst(Maybe.just(d))
    else Maybe.empty

  implicit val monad: Monad[RVar] =
    new Monad[RVar] {
      def bind[A, B](a: RVar[A])(f: A => RVar[B]) =
        a flatMap f
      def point[A](a: => A) =
        RVar.point(a)
    }

  // Find a better home for this
  implicit object DoubleMonoid extends Monoid[Double] {
    def zero = 0.0
    def append(a: Double, b: => Double) = a + b
  }

  implicit def PositionModule[A](implicit sc: Rng[A]) =
    new Module[Position[A],A] {
      implicit def scalar = sc

      def negate(x: Position[A]) = x.map(scalar.negate)
      def zero = Position(NonEmptyList(scalar.zero), NonEmptyList(spire.math.Interval(0.0, 0.0)))

      def plus(x: Position[A], y: Position[A]) = {
        import scalaz.syntax.align._
        x.align(y).map(_.fold(
          s = x => x,<commit_msg>Prevent RVar monad instance hiding things with the same name<commit_after>import scalaz._
import spire.algebra.{Monoid => _, _}
import spire.implicits._
import spire.math.Interval
import spire.math.interval.{Bound,ValueBound}

package object cilib {

//  val ::  = ICons
//  val Nil = INil

  // Should expand into a typeclass? Getter?
  type Selection[A] = (List[A], A) => List[A]
  type Crossover[A] = NonEmptyList[Position[A]] => Step[A,NonEmptyList[Position[A]]]

  type Distance[F[_],A] = (F[A], F[A]) => A

  def positive(d: Double): Maybe[Double @@ Tags.Positive] =
    if (d > 0.0) Tag.subst(Maybe.just(d))
    else Maybe.empty

  def negative(d: Double): Maybe[Double @@ Tags.Negative] =
    if (d < 0.0) Tag.subst(Maybe.just(d))
    else Maybe.empty

  implicit val rvarMonad: Monad[RVar] =
    new Monad[RVar] {
      def bind[A, B](a: RVar[A])(f: A => RVar[B]) =
        a flatMap f
      def point[A](a: => A) =
        RVar.point(a)
    }

  // Find a better home for this
  implicit object DoubleMonoid extends Monoid[Double] {
    def zero = 0.0
    def append(a: Double, b: => Double) = a + b
  }

  implicit def PositionModule[A](implicit sc: Rng[A]) =
    new Module[Position[A],A] {
      implicit def scalar = sc

      def negate(x: Position[A]) = x.map(scalar.negate)
      def zero = Position(NonEmptyList(scalar.zero), NonEmptyList(spire.math.Interval(0.0, 0.0)))

      def plus(x: Position[A], y: Position[A]) = {
        import scalaz.syntax.align._
        x.align(y).map(_.fold(
          s = x => x,
{'fraction_non_alphanumeric': 0.1575274177467597, 'fraction_numerical': 0.006646726487205052, 'mean_word_length': 3.03485254691689, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '397280', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1100, 'n_words': 270}