Skip to content

Instantly share code, notes, and snippets.

Daniel Spiewak djspiewak

Block or report user

Report or block djspiewak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View both.scala
def both[F[_]: Concurrent, A, B](s1: Stream[F, A], s2: Stream[F, B]): Stream[F, (A, B)] = {
def awaitCombine(s: Stream[F, Either[A, B]]): Pull[F, (A, B), Unit] =
s.pull.uncons1 flatMap {
case Some((Left(a), tail)) =>
tail.pull.uncons1 flatMap {
case Some((Right(b), tail)) =>
Pull.output1((a, b)) >> awaitCombine(tail)
case None =>
Pull.done
View Param.scala
/*
* Copyright 2014–2019 SlamData Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View UntypedDestination.scala
/*
* Copyright 2014–2019 SlamData Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View DestinationColumn.scala
/*
* Copyright 2014–2019 SlamData Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View TypeCoercion.scala
/*
* Copyright 2014–2019 SlamData Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View Destination.scala
/*
* Copyright 2014–2019 SlamData Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View tracing-spec.md

Tracing Spec

Tracing is about tracing the structure of an IO computation. Basically, giving some insight into the graph formed by the IO. Tracing is accumulated as the graph is constructed (e.g. by instantiating an IO.Bind node) and reified at the following points:

  • Whenever requested by backtrace: IO[Trace] or printBacktrace: IO[Unit]
  • Whenever an error case is instantiated (IO.Error)

Whenever an exception is rethrown by the interpreter (most commonly in unsafeRunSync()), the associated trace information for that exception should be put into a TracedException wrapper (with cause = the original exception) and that exception should be thrown. This allows backtrace information to participate in side-effectful error recovery and reporting mechanisms. We should consider whether or not we want to also do this with unsafeRunAsync. I'm leaning toward "yes". We should not wrap in TracedException on attempt, raiseError, or any of the other pure error reification mechanisms.

View interruptable.scala
def interruptable[F[_]: Concurrent: ContextShift](thunk: => A): F[A] = {
val fa: F[A] = Concurrent[F] cancelable { cb =>
val done = new AtomicBoolean(false)
val t = new Thread { () =>
try {
val result = thunk
done.set(true)
cb(Right(result))
} catch {
case NonFatal(e) =>
View fromCompletableFuture.scala
def fromCompletableFuture[F[_]: Concurrent: ContextShift, A](
fa: F[CompletableFuture[A]])
: F[A] = {
val wrapped = Concurrent cancelableF[F, A] { k =>
fa flatMap { cf =>
val register = Sync[F] delay {
cf handleAsync { (a, e) =>
if (a == null)
k(e)
else
View resolve-cats-effect-1.4.0.txt
λ coursier resolve org.typelevel:cats-effect_2.12:1.4.0
org.scala-lang:scala-library:2.12.8:default
org.scala-lang:scala-reflect:2.12.6:default
org.typelevel:cats-core_2.12:1.6.0:default
org.typelevel:cats-effect_2.12:1.4.0:default
org.typelevel:cats-kernel_2.12:1.6.0:default
org.typelevel:cats-macros_2.12:1.6.0:default
org.typelevel:machinist_2.12:0.6.6:default
You can’t perform that action at this time.