Skip to content

Instantly share code, notes, and snippets.

@djspiewak
djspiewak / streams-tutorial.md
Created March 22, 2015 19:55
Introduction to scalaz-stream

Introduction to scalaz-stream

Every application ever written can be viewed as some sort of transformation on data. Data can come from different sources, such as a network or a file or user input or the Large Hadron Collider. It can come from many sources all at once to be merged and aggregated in interesting ways, and it can be produced into many different output sinks, such as a network or files or graphical user interfaces. You might produce your output all at once, as a big data dump at the end of the world (right before your program shuts down), or you might produce it more incrementally. Every application fits into this model.

The scalaz-stream project is an attempt to make it easy to construct, test and scale programs that fit within this model (which is to say, everything). It does this by providing an abstraction around a "stream" of data, which is really just this notion of some number of data being sequentially pulled out of some unspecified data source. On top of this abstraction, sca

@markandrus
markandrus / http.hs
Created February 24, 2015 17:55
Sketch for a testable, free monad-based HTTP client
{-#LANGUAGE DataKinds #-}
{-#LANGUAGE DeriveDataTypeable #-}
{-#LANGUAGE DeriveFoldable #-}
{-#LANGUAGE DeriveFunctor #-}
{-#LANGUAGE DeriveGeneric #-}
{-#LANGUAGE DeriveTraversable #-}
{-#LANGUAGE GADTs #-}
{-#LANGUAGE GeneralizedNewtypeDeriving #-}
{-#LANGUAGE KindSignatures #-}
{-#LANGUAGE TypeFamilies #-}
@propensive
propensive / validation.scala
Last active August 29, 2015 14:15
String validation using intersection types and invariant typeclasses
Welcome to Scala version 2.11.5 (OpenJDK 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.
// Define a `Parser` typeclass. This must be invariant.
scala> trait Parser[T] { def parse(s: String): Option[T] }
defined trait Parser
// Here are a couple of typeclass instances to show it working
scala> implicit val identityParser = new Parser[String] { def parse(s: String) = Some(s) }
@ixtli
ixtli / .vimrc
Last active August 29, 2015 14:12
" A config meant for MacVim on OS 10.9/10.10
" Before running VundleInstall:
" Have powerline fonts installed (https://github.com/powerline/fonts)
" Install the reattach to user namespace stuff if using tmux
" 1) brew install reattach-to-user-namespace
" 2) add the following to .tmux.conf:
" set-option -g default-command "reattach-to-user-namespace -l /bin/bash"
"
" After running VundleInstall:
package slick
/**
* This is some code extracted from TimeOut codebase, demonstrating:
* - Use of tag typed to avoid mixing session of different DB
* - The use of the Reader Monad to compose Actions together and defer the choice of async/sync computation
*
* I remove the part where we can say if our operation are read only or not (to use different connection), in order to
* make things easier.
**/