Skip to content

Instantly share code, notes, and snippets.

John A. De Goes jdegoes

Block or report user

Report or block jdegoes

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
jdegoes / zio-test.scala
Last active Oct 19, 2019
Simple example of testing with ZIO environment
View zio-test.scala
object test {
import scalaz.zio._
type UserID = String
case class UserProfile(name: String)
// The database module:
trait Database {
val database: Database.Service
View Hangman.scala
// Create a type class to describe `printLine` and `readLine`.
trait Console[F[_]] {
def printLine(line: String): F[Unit]
def readLine: F[String]
jdegoes / fpmax.scala
Created Jul 13, 2018
FP to the Max — Code Examples
View fpmax.scala
package fpmax
import scala.util.Try
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
jdegoes / afp-examples.scala
Last active Feb 12, 2019
Example code from Applied Functional Programming with Scala
View afp-examples.scala
package lambdaconf.introfp2
// import scalaz._
// import Scalaz._
object functions {
object totality {
///def f[A]: A = null
def g[A]: A = throw new Error
View GameWorld.scala
object game {
case class Lens[S, A](set: A => S => S, get: S => A) { self =>
def >>> [B](that: Lens[A, B]): Lens[S, B] =
Lens[S, B](
set = (b: B) => (s: S) => self.set(that.set(b)(self.get(s)))(s),
get = (s: S) => that.get(self.get(s))
case class Prism[S, A](set: A => S, get: S => Option[A]) { self =>
jdegoes / AsyncToIO.scala
Last active Nov 11, 2017
A sketch of an `Async ~> IO`
View AsyncToIO.scala
val AsyncToIO: NaturalTransformation[Async, IO] {
def apply[A](fa: Async[A]): IO[A] = {
for {
ref <- newIORef[Either[Throwable, A]](Left(new Error("No value")))
counter <- IO(new java.util.concurrent.CountDownLatch(1))
_ <- fa.register(v => ref.set(v).flatMap(_ => IO(counter.countDown()))
_ <- IO(counter.await())
v <- ref.get
a <- v match {
case Left(e) =>
jdegoes /
Created Feb 1, 2017
SlamData Contributor's License Agreement

Quasar Contributor License Agreement

Thank you for your interest in contributing to the Quasar open source project.

This contributor agreement ("Agreement") describes the terms and conditions under which you may Submit a Contribution to Us. By Submitting a Contribution to Us, you accept the terms and conditions in the Agreement. If you do not accept the terms and conditions in the Agreement, you must not Submit any Contribution to Us.

This is a legally binding document, so please read it carefully before accepting the terms and conditions. If you accept this Agreement, the then-current version of this Agreement shall apply each time you Submit a Contribution. The Agreement may cover more than one software project managed by Us.

1. Definitions

jdegoes / example.ejson
Created Jan 19, 2017
EJSON: Extended JSON
View example.ejson
"string-key": 1,
{1: "non-string-key"}: true,
"metadata-on-key" @ true : "metadata-on-value" @ [1, 2, "metadata-on-metadata" @ null]
jdegoes / IOTask.scala
Last active Nov 11, 2017
Pedagogical synchronous and asynchronous effect monads in Scala.
View IOTask.scala
case class IO[A](unsafePerformIO: () => A) { self =>
def map[B](ab: A => B): IO[B] =
IO(() => ab(unsafePerformIO()))
def flatMap[B](afb: A => IO[B]): IO[B] =
IO(() => afb(unsafePerformIO()).unsafePerformIO())
def attempt: IO[Either[Throwable, A]] =
IO(() => try { Right(unsafePerformIO()) } catch { case t : Throwable => Left(t) })
def forkIO: Task[A] = Task(f => IO(unsafePerformIO = () => {
new java.lang.Thread {
override def run: Unit = {
jdegoes / SeqPar.purs
Created Oct 27, 2016
Free applicative in free monad
View SeqPar.purs
-- A sequential series of parallel program fragments in `f`:
type SeqPar f a = Free (FreeAp f) a
liftFA :: forall f a. f a -> SeqPar f a
liftFA = pure >>> pure
liftSeq :: forall f a. Free f a -> SeqPar f a
liftSeq fa = foldFree fa liftFA
liftPar :: forall f a. FreeAp f a -> SeqPar f a
You can’t perform that action at this time.