This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats._ | |
import cats.implicits._ | |
final case class Allocator[F[_], -T, A] private (slotCount: Int, builder: List[T] => F[A]) { | |
def map[B](fn: A => B)(implicit F: Functor[F]): Allocator[F, T, B] = | |
Allocator(slotCount, builder.andThen(_.map(fn))) | |
def pipeTo[T1 <: T, B](that: Allocator[F, T1, A => B])(implicit F: Applicative[F]): Allocator[F, T1, B] = | |
Allocator(slotCount + that.slotCount, | |
{ (slots) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs2.{Chunk, Stream, Pull} | |
import cats.collections.Heap | |
import cats.implicits._ | |
object SortMerge { | |
def sortMerge[F[_], A: Ordering](streams: List[Stream[F, A]]): Stream[F, A] = { | |
implicit val ord: cats.Order[Stream.StepLeg[F, A]] = | |
new cats.Order[Stream.StepLeg[F, A]] { | |
val ordA = implicitly[Ordering[A]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// unfortunately | |
// opaque type Fix[F[_]] = F[Fix[F]] | |
// won't work (no recursion in opaque type), but this implementation is safe, but scary due to asInstanceOf | |
object FixImpl { | |
type Fix[F[_]] | |
inline def fix[F[_]](f: F[Fix[F]]): Fix[F] = f.asInstanceOf[Fix[F]] | |
inline def unfix[F[_]](f: Fix[F]): F[Fix[F]] = f.asInstanceOf[F[Fix[F]]] | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dev.posco.hiona | |
import cats.collections.PairingHeap | |
import cats.kernel.CommutativeSemigroup | |
import cats.{Eq, Order} | |
import cats.implicits._ | |
/** | |
* This keeps a window of events at most Duration apart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dev.posco.hiona | |
import cats.effect.{IO, Resource} | |
import java.io.{BufferedWriter, FileWriter, PrintWriter} | |
import java.nio.file.Path | |
import net.tixxit.delimited.{ DelimitedFormat, Row => DRow} | |
import shapeless._ | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Timestamp(epochMillis: Long) | |
case class Decay[H <: Double](scaledTime: Double, value: Double) { | |
def timestampDouble(implicit v: ValueOf[H]): Double = | |
scaledTime * v.value | |
def timestamp(implicit v: ValueOf[H]): Timestamp = | |
Timestamp(timestampDouble.toLong) | |
def combine(that: Decay[H]): Decay[H] = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed abstract class Label[K, V] { | |
final def lookForward(duration: Duration): Label[K, V] = | |
Label.LookForward(this, duration) | |
final def zip[W](that: Label[K, W]): Label[K, (V, W)] = | |
Label.Zipped(this, that) | |
final def map[W](fn: V => W): Label[K, W] = | |
mapWithKey(Feature.ValueMap(fn)) | |
final def mapWithKey[W](fn: (K, V) => W): Label[K, W] = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* copyright 2020 P. Oscar Boykin <[email protected]> | |
* licensed under Apache V2 license: https://www.apache.org/licenses/LICENSE-2.0.html | |
* or, at your option, GPLv2 or later: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html | |
*/ | |
package testrunner | |
import io.github.classgraph._ | |
import java.io.PrintWriter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Error: | |
* | |
[info] Compiling 1 Scala source to /home/oscar/oss/olelo/target/scala-0.21/classes ... | |
[error] -- Error: /home/oscar/oss/olelo/src/main/scala/Olelo.scala:13:14 --------------- | |
[error] 13 | p.toExpr | |
[error] | ^ | |
[error] | access to type A from wrong staging level: | |
[error] | - the definition is at level 0, | |
[error] | - but the access is at level 1. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 package PatternExamples | |
2 | |
3 foo = "this is foo" | |
4 bar = "this is bar" | |
5 | |
6 combine = "foo: ${foo} bar: ${bar}" | |
7 | |
8 def operator ==(a, b): | |
9 match string_Order_fn(a, b): | |
10 EQ: True |