Skip to content

Instantly share code, notes, and snippets.

Avatar
🐋
Thinking!

Jonathan Winandy ahoy-jon

🐋
Thinking!
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am ahoy-jon on github.
  • I am ahoy_jon (https://keybase.io/ahoy_jon) on keybase.
  • I have a public key whose fingerprint is 2D1F 3333 68BF 23E6 0B5F 97EC AA13 2117 84F5 5FCC

To claim this, I am signing this object:

View mini-cont.scala
sealed abstract class Cont[Result, +H] {
final def map[H2](fn: H => H2): Cont[Result, H2] = flatMap(h => Cont.pure(fn(h)))
final def flatMap[H2](fn: H => Cont[Result, H2]): Cont[Result, H2] = Cont.FlatMapped(this, fn)
def apply(fn: H => Result): Result
}
object Cont {
case class Wrap[Result, H](f: (H => Result) => Result) extends Cont[Result, H] {
View Iterator.scala
def toIterator[R, E, A](
stream: ZStream[R, E, A]
): ZManaged[R, Nothing, Iterator[Either[E, A]]] = {
/*
* Internal state of a Iterator pulling from a ZStream
*
* It starts as Running
*
* when Running , on pull (hasNext), pull the ZStream and switch to Closed or Value
* when Value , on consume (next), return the Value and switch to Running
View Desctruct.scala
sealed trait Path
case class Field(name: String, child: Option[Path]) extends Path {
override def toString: String = child match {
case None => name
case Some(path) => s"$name.$path"
}
}
View ZIO Stream To Iterator.scala
class ToIterator private (runtime: Runtime[Any]) {
def unsafeCreate[V](q: UIO[stream.Stream[_,V]]): Iterator[V] =
new Iterator[V] {
import ToIterator._
var state: State[V] = Running
val synchronousBlockQueue: BlockingQueue[ValueOrClosed[V]] = new SynchronousQueue[ValueOrClosed[V]]
View ZIO to Iterator.scala
object ZioToSparkIterator {
def toIterator[E, A](q: UIO[stream.Stream[E, A]]): Iterator[Either[E, A]] = new Iterator[Either[E, A]] {
sealed trait State
case object Running extends State
sealed trait ValueOrClosed extends State
case object Closed extends ValueOrClosed
case class Value(value: Either[E, A]) extends ValueOrClosed
View deepEqual.scala
implicit val qTree:DeepEqual[QTree[Unit]] = DeepEqual.anyDeepEqual
//DeepEqual.gen[DescribeLong]
DeepEqual.gen[ParkaAnalysis].explainNotEqual(pa,paFromJson).foreach(println)
assert(pa == paFromJson)
}
}
View DreamSyntax.scala
case class Person(name: String, age: Int)
{
val n:Option[String] = Some("toto")
val a:Option[Int= None
val p:Option[Person] = Person.apply.app(name = n, age = a)
}
{
View Blocking.scala
/*
* Copyright 2017-2019 John A. De Goes and the ZIO Contributors
*
* 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 blocking.scala
/*
* Copyright 2017-2019 John A. De Goes and the ZIO Contributors
*
* 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