<commit_before>package rescala.graph

import rescala.graph.Buffer.CommitStrategy
import rescala.propagation.{Committable, Turn}

import scala.language.{existentials, higherKinds, implicitConversions}

object Buffer {
  type CommitStrategy[A] = (A, A) => A
  def commitAsIs[A](base: A, cur: A): A = cur
  def transactionLocal[A](base: A, cur: A) = base
  def keepPulse[P](base: Pulse[P], cur: Pulse[P]) = cur.keep
}

trait Buffer[A] {
  def transform(f: (A) => A)(implicit turn: Turn[_]): A
  def set(value: A)(implicit turn: Turn[_]): Unit
  def base(implicit turn: Turn[_]): A
  def get(implicit turn: Turn[_]): A
}


trait Struct {
  type Spore[R] <: ReactiveSpore[R]
  type SporeP[P, R] = Spore[R] with SporePulse[P]

  def bud[P, R](initialValue: Pulse[P] = Pulse.none, transient: Boolean = true, initialIncoming: Set[R] = Set.empty[R]): SporeP[P, R]

}

trait ReactiveSpore[R] {

  def incoming(implicit turn: Turn[_]): Set[R]
  def updateIncoming(reactives: Set[R])(implicit turn: Turn[_]): Unit

}
trait SporePulse[P] {

  val pulses: Buffer[Pulse[P]]

}

trait PropagationSpore[R] extends ReactiveSpore[R] {

  def outgoing(implicit turn: Turn[_]): Set[R]
  def discover(reactive: R)(implicit turn: Turn[_]): Unit
  def drop(reactive: R)(implicit turn: Turn[_]): Unit
}

trait PropagationStruct extends Struct {
  override type Spore[R] <: PropagationSpore[R]
}

trait LevelSpore[R] extends PropagationSpore[R] {

  def level(implicit turn: Turn[_]): Int
  def updateLevel(i: Int)(implicit turn: Turn[_]): Int

}

trait LevelStruct extends Struct {
  override type Spore[R] <: LevelSpore[R]
}

abstract class BufferedSporeP[P, R](initialIncoming: Set[R]) extends LevelSpore[R] with SporePulse[P] {
  def buffer[A](default: A, commitStrategy: CommitStrategy[A]): Buffer[A]
  private val _level: Buffer[Int] = buffer(0, math.max)
  private val _incoming: Buffer[Set[R]] = buffer(initialIncoming, Buffer.commitAsIs)
  private val _outgoing: Buffer[Set[R]] = buffer(Set.empty, Buffer.commitAsIs)

  override def level(implicit turn: Turn[_]): Int = _level.get(turn)
  override def updateLevel(i: Int)(implicit turn: Turn[_]): Int = _level.transform(math.max(i, _))

  override def incoming(implicit turn: Turn[_]): Set[R] = _incoming.get
  override def updateIncoming(reactives: Set[R])(implicit turn: Turn[_]): Unit = _incoming.set(reactives.toSet)


  override def outgoing(implicit turn: Turn[_]): Set[R] = _outgoing.get
  override def discover(reactive: R)(implicit turn: Turn[_]): Unit = _outgoing.transform(_ + reactive)
  override def drop(reactive: R)(implicit turn: Turn[_]): Unit = _outgoing.transform(_ - reactive)

}
<commit_msg>remove unused BufferedSpore<commit_after>package rescala.graph

import rescala.propagation.{Committable, Turn}

import scala.language.{existentials, higherKinds, implicitConversions}

object Buffer {
  type CommitStrategy[A] = (A, A) => A
  def commitAsIs[A](base: A, cur: A): A = cur
  def transactionLocal[A](base: A, cur: A) = base
  def keepPulse[P](base: Pulse[P], cur: Pulse[P]) = cur.keep
}

trait Buffer[A] {
  def transform(f: (A) => A)(implicit turn: Turn[_]): A
  def set(value: A)(implicit turn: Turn[_]): Unit
  def base(implicit turn: Turn[_]): A
  def get(implicit turn: Turn[_]): A
}


trait Struct {
  type Spore[R] <: ReactiveSpore[R]
  type SporeP[P, R] = Spore[R] with SporePulse[P]

  def bud[P, R](initialValue: Pulse[P] = Pulse.none, transient: Boolean = true, initialIncoming: Set[R] = Set.empty[R]): SporeP[P, R]

}

trait ReactiveSpore[R] {

  def incoming(implicit turn: Turn[_]): Set[R]
  def updateIncoming(reactives: Set[R])(implicit turn: Turn[_]): Unit

}
trait SporePulse[P] {

  val pulses: Buffer[Pulse[P]]

}

trait PropagationSpore[R] extends ReactiveSpore[R] {

  def outgoing(implicit turn: Turn[_]): Set[R]
  def discover(reactive: R)(implicit turn: Turn[_]): Unit
  def drop(reactive: R)(implicit turn: Turn[_]): Unit
}

trait PropagationStruct extends Struct {
  override type Spore[R] <: PropagationSpore[R]
}

trait LevelSpore[R] extends PropagationSpore[R] {

  def level(implicit turn: Turn[_]): Int
  def updateLevel(i: Int)(implicit turn: Turn[_]): Int

}

trait LevelStruct extends Struct {
  override type Spore[R] <: LevelSpore[R]
}


{'fraction_non_alphanumeric': 0.14633569739952718, 'fraction_numerical': 0.00023640661938534278, 'mean_word_length': 5.371987951807229, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '4816486', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1515, 'n_words': 400}