Bind remote docker.sock with SSH tunnel:
ssh -nNT -L /tmp/docker.sock:/var/run/docker.sock <USER>@<IP> &
Set environment variable for local Docker client:
export DOCKER_HOST=unix:///tmp/docker.sock
package scalax.collection | |
import scala.collection.mutable.ListBuffer | |
/** FoldTransformers and the views based on them are a Scala | |
* adaptation, and to some degree an extension, of Rich Hickey's | |
* transducers for Clojure. They show that the concepts can be | |
* implemented in a type-safe way, and that the implementation is | |
* quite beautiful. | |
*/ | |
object FoldingViews { |
Bind remote docker.sock with SSH tunnel:
ssh -nNT -L /tmp/docker.sock:/var/run/docker.sock <USER>@<IP> &
Set environment variable for local Docker client:
export DOCKER_HOST=unix:///tmp/docker.sock
import $ivy.`org.typelevel::cats-effect:0.10-22efb61`, cats._, cats.implicits._, cats.effect._, scala.concurrent.duration._ | |
def putStr(msg: String): IO[Unit] = IO(print(msg)) | |
def putStrLn(msg: String): IO[Unit] = IO(println(msg)) | |
def readLn: IO[String] = IO(Console.readLine) | |
val now: IO[Long] = IO(System.currentTimeMillis) | |
def time[A](ioa: IO[A]): IO[(FiniteDuration, A)] = for { | |
start <- now |
-- Because of the type of 'from', 'Coaplicative' must correspond to "non-empty containers", for the usual hand-wavy definition of "container". | |
class Functor f => Coapplicative f where | |
from :: f a -> a | |
separate :: f (Either a b) -> Either (f a) (f b) | |
instance Coapplicative Identity where | |
from (Identity a) = a | |
separate (Identity (Left a)) = Left (Identity a) | |
separate (Identity (Right b)) = Right (Identity b) |
module Main where | |
import Prelude | |
import Effect (Effect) | |
import Vanilla.Dom.Document (body) | |
import Vanilla.Dom.Element (setStyle) | |
main :: Effect Unit | |
main = |
{-# language KindSignatures #-} | |
{-# language PolyKinds #-} | |
{-# language DataKinds #-} | |
{-# language TypeFamilies #-} | |
{-# language RankNTypes #-} | |
{-# language NoImplicitPrelude #-} | |
{-# language FlexibleContexts #-} | |
{-# language MultiParamTypeClasses #-} | |
{-# language GADTs #-} | |
{-# language ConstraintKinds #-} |
Fibers are an abstraction over sequential computation, similar to threads but at a higher level. There are two ways to think about this model: by example, and abstractly from first principles. We'll start with the example.
(credit here is very much due to Fabio Labella, who's incredible Scala World talk describes these ideas far better than I can)
Consider the following three functions