Skip to content

Instantly share code, notes, and snippets.

View haghard's full-sized avatar
馃彔
Working from home

Vadim Bondarev haghard

馃彔
Working from home
View GitHub Profile
type | [+A, +B] = Union.Type[A, B]
object Union {
trait Tag extends Any
type Base
type Type[+A, +B] <: Base with Tag
implicit def first[A]: A <:< Type[A, Nothing] =
implicitly[A <:< A].asInstanceOf[A <:< Type[A, Nothing]]
implicit def second[B]: B <:< Type[Nothing, B] =
implicitly[B <:< B].asInstanceOf[B <:< Type[Nothing, B]]
@haghard
haghard / example.scala
Created September 16, 2017 20:53 — forked from SystemFw/example.scala
Running fs2 streams in parallel and collect their result in sequence, with queues
object Example {
import cats._, implicits._
import cats.effect._
import fs2._
import scala.concurrent.ExecutionContext
// start N streams concurrently, and stream their results in order
// e.g. download a file from a server in N parts concurrently, and stream it
// this approach is good for showcasing usage of concurrent abstractions,
// but a lower level implementation using Pull is likely to be much more performant
@haghard
haghard / 0-common.Module.scala
Created September 11, 2016 16:02 — forked from aloiscochard/0-common.Module.scala
Dependency Injection in Scala without Cake Pattern
package com.acme
import com.typesafe.config.Config
trait Module {
implicit def config: Config
}
@haghard
haghard / Task.scala
Created January 6, 2016 12:56 — forked from shajra/Task.scala
integration code between Scalaz and Scala standard concurrency libraries.
import concurrent.{ExecutionContext, Future => SFuture, Promise}
import util.Try
import _root_.scalaz.\/
import _root_.scalaz.concurrent.{Task => ZTask}
object Task {
def fromScala[A]
@haghard
haghard / jargon.md
Last active August 29, 2015 14:26 — forked from cb372/jargon.md
Category theory jargon cheat sheet

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.

import reflect.ClassTag
trait Semigroup[F]{
def append(a1: F, a2: F): F
def apply: Apply[({type 位[伪]=F})#位] = new SemigroupApply{}
protected[this] trait SemigroupApply extends Apply[({type 位[伪]=F})#位]{
override def map[A, B: ClassTag](fa)(f) = fa
override def ap[A, B: ClassTag](fa)(f) = append(fa, f)
// This should work with Scala 2.10.4 & scalaz 7.1, core, effect and concurrent packages
import scalaz.{ concurrent, Free, Functor, Monad, syntax }
import concurrent.Task
import Free.{freeMonad => _, _}
import syntax.monad._
// Describe the set of actions - which are functors
sealed trait RedisF[+A] {
def map[B](fn: A => B): RedisF[B]
package org.iainhull.akka
import scala.concurrent.duration._
import akka.actor._
import akka.event.Logging
import akka.pattern.ask
import akka.util.Timeout
import akka.persistence.{PersistentView, AtLeastOnceDelivery, PersistentActor}
import java.util.regex.Pattern
import play.core.Routes
import play.api.mvc._
object Router extends Routes {
def routes = {
// Static paths
case Route("GET", p"") => controllers.Application.index
case Route("GET", p"/items") => controllers.Items.list

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

Monday June 16th