you can geek out a bit here. Let's assume you have Int as you seem to above:
val intAve = AveragedValue.numericAggregator[Int]
// Now we actually have Option[Int], so we add a second aggregator
val unitAggregator = Aggregator.fromMoniod[Unit]
// now combine:
val opt: MonoidAggregator[Option[Int], _, Option[Double]] = unitAggregator.either(intAve)
.composePrepare { opt: Option[Int] =>
opt match {
case None => Left(()) // unit
case Some(i) => Right(i)
}
}
.andThenPresent { case (_, av) =>
if (av.count == 0L) None else Some(av.value)
}
something like that should work.