View gist:20d5badbe7a09a7ec71d0ca3017d1096
object KafkaStreamsTest extends TestSuite[KafkaLocalServer] with Serializers {
def setup(): KafkaLocalServer = {
val s = KafkaLocalServer(true)
s.start()
s
}
def tearDown(server: KafkaLocalServer): Unit = {
server.stop()
}
View gist:26ccf7aa8db72d51924c53fc7b769ddc
// build.sbt
val catsVersion = "1.0.0-RC1"
val catsEffectVersion = "0.5"
val catsCore = "org.typelevel" % "cats-core_2.12" % catsVersion
val catsFree = "org.typelevel" % "cats-free_2.12" % catsVersion
val catsEffect = "org.typelevel" %% "cats-effect" % catsEffectVersion
val monix = "io.monix" %% "monix" % "3.0.0-8084549"
val monixCats = "io.monix" %% "monix-cats" % "2.3.2"
View Haskell
yonedaLemma = Iso (flip fmap) ($ id)
View cqrs.session
scala> import frdomain.ch8.cqrs.service._
import frdomain.ch8.cqrs.service._
scala> import Scripts._
import Scripts._
scala> import RepositoryBackedAccountInterpreter._
import RepositoryBackedAccountInterpreter._
scala> RepositoryBackedAccountInterpreter(composite)
View type-inhabitants.markdown

This is material to go along with a 2014 Boston Haskell talk.

We are going to look at a series of type signatures in Haskell and explore how parametricity (or lack thereof) lets us constrain what a function is allowed to do.

Let's start with a decidedly non-generic function signature. What are the possible implementations of this function which typecheck?

wrangle :: Int -> Int
View gist:f473167ac91b2af4949c6340d4aa0c1b
// Finally tagless lambda calculus
object Final {
def varZ[A,B](env1: A, env2: B): A = env1
def varS[A,B,T](vp: B => T)(env1: A, env2: B): T = vp(env2)
def b[E](bv: Boolean)(env: E): Boolean = bv
def lam[A,E,T](e: (A, E) => T)(env: E): A => T = x => e(x, env)
def app[A,E,T](e1: E => A => T, e2: E => A)(env: E): T = e1(env)(e2(env))
def testf1[E,A](env: E): Boolean =
app(lam[Boolean,E,Boolean](varZ) _, b(true))(env)
View build.sbt
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")
View gist:9fe9037d9a94595b35e96529fcdd4e9a
Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> import numpy
>>> data_dir = "/Users/debasishghosh/temp/ingest-intrusion-data/ingest-intrusiondata-tmp"
>>> train_data = data_dir + "/new_train_data.csv"
>>> train_labels = data_dir + "/train_labels.csv"
>>> test_data = data_dir + "/new_test_data.csv"
>>> test_labels = data_dir + "/test_labels.csv"
View gist:3adf3bde24336b5d4cef7f5eefe8367f
Debasishs-MacBook-Pro:skil-distro-1.1-SNAPSHOT debasishghosh$ /usr/bin/java -cp /Users/debasishghosh/skymind/lagom-skil-api/skildistro/target/skil-distro-1.1-SNAPSHOT/lib/*:/Users/debasishghosh/skymind/lagom-skil-api/skildistro/target/skil-distro-1.1-SNAPSHOT/native/*:/Users/debasishghosh/skymind/lagom-skil-api/skildistro/target/skil-distro-1.1-SNAPSHOT/lib/ext/* -Dplay.crypto.secret=as8dufasdfuasdfjkasdkfalksjfk io.skymind.skil.daemon.ProcessLauncherDaemon -port 9000
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/debasishghosh/skymind/lagom-skil-api/skildistro/target/skil-distro-1.1-SNAPSHOT/lib/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/debasishghosh/skymind/lagom-skil-api/skildistro/target/skil-distro-1.1-SNAPSHOT/lib/slf4j-log4j12-1.7.19.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
20:39:18,894 |-INFO in ch.qos.log