import cats.Monad | |
import cats.effect.concurrent.{Ref, Semaphore} | |
import cats.effect.{Concurrent, Resource} | |
import cats.implicits._ | |
import fs2.{Pipe, Stream} | |
import fs2.concurrent.{NoneTerminatedQueue, Queue} | |
/** Represents the ability to enqueue keyed items into a stream of queues that emits homogenous keyed streams. | |
* |
This note outlines a principled way to meta-programming in Scala. It tries to combine the best ideas from LMS and Scala macros in a minimalistic design.
-
LMS: Types matter. Inputs, outputs and transformations should all be statically typed.
-
Macros: Quotations are ultimately more easy to deal with than implicit-based type-lifting
-
LMS: Some of the most interesting and powerful applications of meta-programming
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 | |
abstract class Channel[F[_], A] { |
Edit: This list is now maintained in the rust-anthology repo.
# Download latest archlinux bootstrap package, see https://www.archlinux.org/download/ | |
wget 'ftp://ftp.nluug.nl/pub/os/Linux/distr/archlinux/iso/latest/archlinux-bootstrap-*-x86_64.tar.gz' | |
# Make sure you'll have enough entropy for pacman-key later. | |
apt-get install haveged | |
# Install the arch bootstrap image in a tmpfs. | |
mount -t tmpfs none /mnt | |
cd /mnt | |
tar xvf ~/archlinux-bootstrap-*-x86_64.tar.gz --strip-components=1 |
Java 8 introduced lambdas to the Java language. While the design choices differ in many regards from Scala's functions, the underlying mechanics used to represent Java lambdas is flexible enough to be used as a target for the Scala compiler.
Java does not have canonical heirarchy of generic function types (ala scala.FunctionN
), but instead allows a lambda to be used as a shorthand for an anonymous implementation of an Functional Interface
Here's an example of creating a predicate that closes over one value:
// List comprehension in C++11 in form of SQL-like syntax | |
// Example code from http://vitiy.info/cpp11-writing-list-comprehension-in-form-of-sql/ | |
// Written by Victor Laskin ([email protected]) | |
#include <iostream> | |
#include <functional> | |
#include <vector> | |
#include <future> | |
#include <algorithm> | |
using namespace std; |
#Intro
Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3
Kotlin project website is at kotlin.jetbrains.org.
All the codes here can be copied and run on Kotlin online editor.
Let's get started.