<commit_before>package scalan

import scalan._
import scalan.primitives._
import scalan.primitives.NumericOps

trait Monoids { self: Scalan =>
  class RepMonoid[A](val opName: String, val append: (Rep[A], => Rep[A]) => Rep[A], val zero: Rep[A], val infix: Boolean)(implicit eA: Elem[A]) {
    override def toString = s"Monoid[${eA.prettyName}]($opName, $zero)"
  }
  
  object RepMonoid {
    def apply[A](opName: String, append: (Rep[A], => Rep[A]) => Rep[A], zero: A, infix: Boolean)(implicit eA: Elem[A]): RepMonoid[A] =
      new RepMonoid(opName, append, toRep(zero), infix)
  }
  
  implicit lazy val IntRepPlusMonoid: RepMonoid[Int] = RepMonoid("+", (a, b) => a + b, 0, true)
  implicit lazy val FloatRepPlusMonoid: RepMonoid[Float] = RepMonoid("+", (a, b) => a + b, 0f, true)
  implicit lazy val BooleanRepOrMonoid: RepMonoid[Boolean] = RepMonoid("||", (a, b) => a || b, false, true)

  lazy val IntRepMultMonoid = RepMonoid[Int]("*", (a, b) => a * b, 1, true)
  lazy val FloatRepMultMonoid = RepMonoid[Float]("*", (a, b) => a * b, 1f, true)
  lazy val BooleanRepAndMonoid = RepMonoid[Boolean]("&&", (a, b) => a && b, true, true)
  
  def isPredefined(m: RepMonoid[_]): Boolean = {
    Set[RepMonoid[_]](IntRepMultMonoid,
      IntRepPlusMonoid,
      FloatRepMultMonoid,
      FloatRepPlusMonoid,
      BooleanRepAndMonoid,
      BooleanRepOrMonoid).contains(m)}
}<commit_msg>Added isCommutative to RepMonoid<commit_after>package scalan

import scalan._
import scalan.primitives._
import scalan.primitives.NumericOps

trait Monoids { self: Scalan =>
  class RepMonoid[A](val opName: String, val append: (Rep[A], => Rep[A]) => Rep[A], val zero: Rep[A], val isInfix: Boolean, val isCommutative: Boolean)(implicit eA: Elem[A]) {
    override def toString = s"Monoid[${eA.prettyName}]($opName, $zero)"
  }
  
  object RepMonoid {
    def apply[A](opName: String, append: (Rep[A], => Rep[A]) => Rep[A], zero: A, isInfix: Boolean, isCommutative: Boolean)(implicit eA: Elem[A]): RepMonoid[A] =
      new RepMonoid(opName, append, toRep(zero), isInfix, isCommutative)
  }
  
  implicit lazy val IntRepPlusMonoid: RepMonoid[Int] = 
    RepMonoid("+", (a, b) => a + b, 0, isInfix = true, isCommutative = true)
  implicit lazy val FloatRepPlusMonoid: RepMonoid[Float] = 
    RepMonoid("+", (a, b) => a + b, 0f, isInfix = true, isCommutative = true)
  implicit lazy val BooleanRepOrMonoid: RepMonoid[Boolean] = 
    RepMonoid("||", (a, b) => a || b, false, isInfix = true, isCommutative = true)

  lazy val IntRepMultMonoid = 
    RepMonoid[Int]("*", (a, b) => a * b, 1, isInfix = true, isCommutative = true)
  lazy val FloatRepMultMonoid = 
    RepMonoid[Float]("*", (a, b) => a * b, 1f, isInfix = true, isCommutative = true)
  lazy val BooleanRepAndMonoid = 
    RepMonoid[Boolean]("&&", (a, b) => a && b, true, isInfix = true, isCommutative = true)
  
  def isPredefined(m: RepMonoid[_]): Boolean = {
    Set[RepMonoid[_]](IntRepMultMonoid,
      IntRepPlusMonoid,
      FloatRepMultMonoid,
      FloatRepPlusMonoid,
      BooleanRepAndMonoid,
      BooleanRepOrMonoid).contains(m)}
}
{'fraction_non_alphanumeric': 0.15920881971465628, 'fraction_numerical': 0.0025940337224383916, 'mean_word_length': 4.374564459930314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2544266', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1160, 'n_words': 289}