Skip to content

Instantly share code, notes, and snippets.

@lamdor
lamdor / build.sbt
Last active May 26, 2021 21:27
Playing around with tagless final style and Eff (from https://github.com/edmundnoble/final-tagless-typelevel-summit)
scalaVersion := "2.11.8"
scalaOrganization := "org.typelevel"
libraryDependencies ++= Seq(
"org.typelevel" %% "cats" % "0.9.0",
"org.atnos" %% "eff" % "4.0.0"
)
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.3")
@tlockney
tlockney / tmux.conf
Last active May 18, 2017 13:53
Make tmux awesome (probably not nearly as awesome as it *could* be)
# set the command prefix to `
set -g prefix "`"
unbind C-b
bind "`" send-prefix
# listen to alerts from all windows
set -g bell-action any
set -g default-shell /usr/local/bin/fish
set -g default-command fish

Take-home functional programming interview

This document is licensed CC0.

These are some questions to give a sense of what you know about FP. This is more of a gauge of what you know, it's not necessarily expected that a single person will breeze through all questions. For each question, give your answer if you know it, say how long it took you, and say whether it was 'trivial', 'easy', 'medium', 'hard', or 'I don't know'. Give your answers in Haskell for the questions that involve code.

Please be honest, as the interviewer may do some spot checking with similar questions. It's not going to look good if you report a question as being 'trivial' but a similar question completely stumps you.

Here's a bit more guidance on how to use these labels:

@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

@jstrachan
jstrachan / gist:f960917b4861f30a8a45
Last active August 29, 2015 14:02
names your iTerm2 tab after the current working directory, shows the path in the prompt and the git branch
# thanks to this gist for the iTerm2 tab naming stuff: https://gist.github.com/phette23/5270658
# can't remember where I cribbed the rest of this from!
# hacked it a bit to work on OS X
_bold=$(tput bold)
_normal=$(tput sgr0)
__vcs_dir() {
local vcs base_dir sub_dir ref
sub_dir() {
@pchiusano
pchiusano / finallytagless.scala
Last active March 13, 2018 11:28
Finally tagless encoding of GADTs in Scala
trait ConsoleAlg[F[_]] {
def readLine: F[Option[String]]
def printLine(line: String): F[Unit]
}
trait Console[+A] {
def run[F[+_]](F: ConsoleAlg[F]): F[A]
}
object Console {
@bmjames
bmjames / gist:9669467
Created March 20, 2014 17:37
Comparing Scala's List#map to Haskell's map
-- http://hackage.haskell.org/package/base-4.6.0.1/docs/src/GHC-Base.html#map
map :: (a -> b) -> [a] -> [b]
map _ [] = []
map f (x:xs) = f x : map f xs
@runarorama
runarorama / gist:9422453
Last active August 29, 2015 13:57
Suggestion for the new representation of `IO` in Scalaz.
import scalaz._
import \/._
import Free._
import scalaz.syntax.monad._
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.CountDownLatch
object Experiment {
sealed trait OI[A] {
def map[B](f: A => B): OI[B]
import scala.util.control.Exception
import scalaz._
import scalaz.Free.FreeC
import scalaz.Scalaz._
object Kasten {
/////////////////////////
// The State stuff
/////////////////////////
import Web.Scotty.Trans
import Network.Wai.Middleware.RequestLogger
import Network.Wai.Middleware.Static
import Text.Blaze.Html.Renderer.Text (renderHtml)
import System.Environment
import Database.Persist.Sql (SqlPersistT(..), Connection, runMigration, runSqlPersistM, runSqlConn, unSqlPersistT)
import Database.Persist.Postgresql (withPostgresqlConn)
setup :: ScottyT Text (SqlPersistT (NoLoggingT (ResourceT IO))) () -> IO ()
setup m = do