<commit_before>package io.github.andrebeat.bytes

trait Write[A] {
  def apply(bytes: Bytes, offset: Int, value: A): Unit
}

object Write {
  implicit object ByteWrite extends Write[Byte] {
    def apply(bytes: Bytes, offset: Int, value: Byte) = bytes.writeByte(offset, value)
  }

  implicit object ShortWrite extends Write[Short] {
    def apply(bytes: Bytes, offset: Int, value: Short) = bytes.writeShort(offset, value)
  }

  implicit object CharWrite extends Write[Char] {
    def apply(bytes: Bytes, offset: Int, value: Char) = bytes.writeChar(offset, value)
  }

  implicit object IntWrite extends Write[Int] {
    def apply(bytes: Bytes, offset: Int, value: Int) = bytes.writeInt(offset, value)
  }

  implicit object FloatWrite extends Write[Float] {
    def apply(bytes: Bytes, offset: Int, value: Float) = bytes.writeFloat(offset, value)
  }

  implicit object LongWrite extends Write[Long] {
    def apply(bytes: Bytes, offset: Int, value: Long) = bytes.writeLong(offset, value)
  }

  implicit object DoubleWrite extends Write[Double] {
    def apply(bytes: Bytes, offset: Int, value: Double) = bytes.writeDouble(offset, value)
  }
}<commit_msg>Write: return number of bytes written<commit_after>package io.github.andrebeat.bytes

trait Write[A] {
  def apply(bytes: Bytes, offset: Int, value: A): Int
}

object Write {
  implicit object ByteWrite extends Write[Byte] {
    def apply(bytes: Bytes, offset: Int, value: Byte): Int = {
      bytes.writeByte(offset, value)
      1
    }
  }

  implicit object ShortWrite extends Write[Short] {
    def apply(bytes: Bytes, offset: Int, value: Short) = {
      bytes.writeShort(offset, value)
      2
    }
  }

  implicit object CharWrite extends Write[Char] {
    def apply(bytes: Bytes, offset: Int, value: Char) = {
      bytes.writeChar(offset, value)
      2
    }
  }

  implicit object IntWrite extends Write[Int] {
    def apply(bytes: Bytes, offset: Int, value: Int) = {
      bytes.writeInt(offset, value)
      4
    }
  }

  implicit object FloatWrite extends Write[Float] {
    def apply(bytes: Bytes, offset: Int, value: Float) = {
      bytes.writeFloat(offset, value)
      4
    }
  }

  implicit object LongWrite extends Write[Long] {
    def apply(bytes: Bytes, offset: Int, value: Long) = {
      bytes.writeLong(offset, value)
      8
    }
  }

  implicit object DoubleWrite extends Write[Double] {
    def apply(bytes: Bytes, offset: Int, value: Double) = {
      bytes.writeDouble(offset, value)
      8
    }
  }
}
{'fraction_non_alphanumeric': 0.11208967173738991, 'fraction_numerical': 0.0028022417934347476, 'mean_word_length': 3.4308510638297873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4040827', 'n_tokens_mistral': 793, 'n_tokens_neox': 795, 'n_words': 237}